• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

JavaMail will not let me to authenticate myself

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I am able to authenticate myself to my ISP SMTP server through telnet and send (relay) emails to external domains.

HOWEVER for some obscure reason, I cannot do this through the JavaMail API. Could anyone let me know what is wrong with my code?

I appreciate your help.



While executing the code I am getting this error:




The code above does work if I try to send the email within smtp.my.isp.com (which does not require authentication), but it fails if I try to email it to some external SMTP server. Probably I am not getting authenticated with my ISP SMTP server. But Why???


[ July 20, 2007: Message edited by: Joseph Sweet ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just resolved a problem like yours, hope this is helpful.
As this doc:http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html
the smtp authentication is forbidden by default, if you mail server don't require an authentication, you app could connect the server without problem.
But if it need, you need declare it be true before create a connection.

Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --
// -- Could use Session.getTransport() and Transport.connect()
// , but assume we're using SMTP --

props.put("mail.smtp.host", smtpServer);
// add this line
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, null);
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic