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 ]
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);
posted 13 years ago
We must know, we will know. -- David Hilbert
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?