aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes JavaMail will not let me to authenticate myself Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "JavaMail will not let me to authenticate myself" Watch "JavaMail will not let me to authenticate myself" New topic
Author

JavaMail will not let me to authenticate myself

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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 ]

We must know, we will know. -- David Hilbert
wupeng wu
Greenhorn

Joined: Jul 24, 2007
Posts: 1
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

Joined: Jan 29, 2005
Posts: 327
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaMail will not let me to authenticate myself