Javamail STMP send trouble

A

aostrik

Hi ALL,
I've looked thru the archive of this group regarding Javamail but could
not find answer to my problem:
I just want to send a message.
HERE IS MY CODE:

String host = "...";
int port = 2525;
String from = "myname@myserver";
String to = "(e-mail address removed)";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.auth", true);

// Get session
Session session = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(session);

try
{
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
message.saveChanges();

// Send message
Transport tr = session.getTransport("smtp");
tr.connect(host, port, "mylogin", "mypsw");
tr.sendMessage(message, message.getAllRecipients());
tr.close();
}
catch (MessagingException e)
{
e.printStackTrace();
}

AND HERE IS EXCEPTION THAT I GET:

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 473
(e-mail address removed) You need to use SMTP authentification

at
com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at
com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at snmpmonitoring.Controller.sendEmails(Controller.java:155)
at
snmpmonitoring.servlets.SendEmailServlet.service(SendEmailServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 473
(e-mail address removed) You need to use SMTP authentification

at
com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1094)
... 19 more

Looks like it recomend me using SMTP authentification, but I have
turned it on already.
COuld you tell me where is my problem.

Thank you.
 
R

Rico

Hi ALL,
I've looked thru the archive of this group regarding Javamail but could
not find answer to my problem:
I just want to send a message.
HERE IS MY CODE:

// Setup mail server
props.put("mail.smtp.auth", true);


Muahahaha. Believe me, I'm laughing _with_ you :)
props.put("mail.smtp.auth", true);

should be

props.put("mail.smtp.auth", "true");

Muahahaha.

Rico.
 
A

aostrik

Muahahaha. Believe me, I'm laughing _with_ you :)


should be

props.put("mail.smtp.auth", "true");

Muahahaha.

Rico.

:))))))))))))))))))))))))
Sometimes it happens.
Thank you for pointing out.
 
E

EJP

Rico said:
Muahahaha. Believe me, I'm laughing _with_ you :)




should be

props.put("mail.smtp.auth", "true");

or better still props.setProperty( ... ), and the compiler wouldn't have
let you make the mistake in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top