This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Initially I thought that the "fromaddress" that I am using requires an authentication. But that is not the case. It has been configured to send mail without any authentication. Then when I changed the configuration to enabled authentication, I am still getting the same error. I am putting the whole SMTP Debug as well as my code here. Note that my user id for authentication is same as "from address" i.e. firstname.lastname@example.org
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "192.168.21.223", port 25, isSSL false
220 MAIL1.XXXX.INT Microsoft ESMTP MAIL Service ready at Mon, 23 Jan 2012 18:23:56 +0200
DEBUG SMTP: connected to host "192.168.21.223", port: 25
250-MAIL1.XXXX.INT Hello [10.160.1.110]
250-X-EXPS GSSAPI NTLM
DEBUG SMTP: Found extension "SIZE", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "X-ANONYMOUSTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "NTLM"
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "XEXCH50", arg ""
DEBUG SMTP: Found extension "XRDST", arg ""
DEBUG SMTP: Found extension "XSHADOW", arg ""
DEBUG SMTP: Attempt to authenticate
250 2.0.0 OK
DEBUG SMTP: use8bit false
530 5.7.1 Client was not authenticated
DEBUG SMTP: got response code 530, with response: 530 5.7.1 Client was not authenticated
DEBUG SMTP: EOF: [EOF]
What do you mean, with authentication? There is no authentication in that code. Have a look at the JavaMail FAQ, where you'll find an example of how to do it.
Joined: Oct 29, 2006
Referring to Java doc link that you posted:
You need to authenticate to your SMTP server. The package javadocs for the com.sun.mail.smtp package describe several methods to do this. The easiest is often to replace the call Transport.send(msg); with
Priyam Srivastava wrote:...only difference being which overloaded connect method I am using? Or am I missing something?
Yes. The code you showed from the FAQ provides a user ID and password. Your code (which the server doesn't believe authenticates) does not provide a user ID and password. Do you think that is an insignificant difference?
Joined: Oct 29, 2006
If You are referring to variable l_user, l_passwd then this is getting populated from my Properties file for which I haven't pasted the code here.
l_user = email@example.com l_passwd = xxxxxxxx
No, of course just setting variables in your code to the user ID and password wouldn't cause authentication with the SMTP server. So no, I wasn't referring to that. I was referring to the total absence of any code where you pass that information to the server. Or if you do, I can't see it. (My apologies if it's actually there -- I find your code very hard to read with all those strange variable names.)
But you've seen the example code. It works. Your code is different, and it doesn't work. I know what I would do in that case. I'm surprised you haven't done it yourself already.