Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Javamail STMP send trouble

Thread view: 
aostrik@gmail.com - 06 Jun 2006 13:26 GMT
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 = "other_name@gmail.com";

      // 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
aostrik@gmail.com 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
aostrik@gmail.com 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.
Rico - 06 Jun 2006 16:01 GMT
> Hi ALL,
> I've looked thru the archive of this group regarding Javamail but could
[quoted text clipped - 4 lines]
>        // 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.
aostrik@gmail.com - 06 Jun 2006 16:41 GMT
> >        // Setup mail server
> >        props.put("mail.smtp.auth", true);
[quoted text clipped - 10 lines]
>
> Rico.

:))))))))))))))))))))))))
Sometimes it happens.
Thank you for pointing out.
EJP - 07 Jun 2006 04:08 GMT
>>Hi ALL,
>>I've looked thru the archive of this group regarding Javamail but could
[quoted text clipped - 12 lines]
>    
>     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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.