Hello!
I use javamail, and cannot send mail =(
code:
String host = "krypton.lunarpages.com";
String user = "login_to_ftp";
String password = "password_to_ftp";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
Session mailSession = Session.getDefaultInstance(props, null);
try {
MimeMessage msg = new MimeMessage(mailSession);
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("onepavel@yandex.ru"));
msg.setFrom(new InternetAddress("newsletter@iconsoft.com"));
msg.setSubject("Test");
msg.setText("Hi");
Transport transport = null;
transport = mailSession.getTransport("smtp");
transport.connect(host, user, password);
transport.send(msg);
}
catch (Exception e) {
PrintWriter writer = new PrintWriter(out);
e.printStackTrace(writer);
}
finally {
if (transport != null) {
try { transport.close(); }
catch (MessagingException e) {}
}
}
I receive result:
javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at _jsp._sender__jsp._jspService(_sender__jsp.java:65)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
What's the problem?
I think, I use wrong passwords.
Please, help me.