Hi,
While sending Email... I keep getting error:
530 5.7.1 Client was not authenticated
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 authentication required, 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. xxxxx@abcd.com
>
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
EHLO venus02
250-MAIL1.XXXX.INT Hello [10.160.1.110]
250-SIZE
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
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
NOOP
250 2.0.0 OK
DEBUG SMTP: use8bit false
MAIL FROM:<xxxxx@abcd.com>
530 5.7.1 Client was not authenticated
DEBUG SMTP: got response code 530, with response: 530 5.7.1 Client was not authenticated
RSET
DEBUG SMTP: EOF: [EOF]
javax.mail.MessagingException: [EOF]
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1512)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1055)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:634)
at com.pack.prod.infra.JFMailer.sendMail(JFMailer.java:843)
>
My Java code goes like this:
view plaincopy to clipboardprint?
l_auth = new EmailAuthenticator (l_user, l_passwd);
//EmailAuthenticator extends Authenticator
l_smtp_properties = new Properties ();
l_smtp_properties.setProperty ("mail.smtp.host", "192.168.21.223");
l_smtp_properties.setProperty ("mail.smtp.from", "xxxxx@abcd.com");
l_smtp_properties.setProperty ("mail.smtp.auth", "true");
smtpSession = Session.getInstance (l_smtp_properties, l_auth);
smtpSession.setDebug (true);
smtpTransport = smtpSession.getTransport ("smtp");
smtpTransport.connect (smtpSession.getProperty ("mail.smtp.host"), 25, l_user, l_passwd);
l_smtp_message = new MimeMessage (smtpSession);
l_addr[0] = new InternetAddress (p_from_addr);
l_smtp_message.addFrom (l_addr);
l_smtp_message.addRecipient (Message.RecipientType.TO, new InternetAddress ("me@gmail.com"));
l_mimemultipart = new MimeMultipart ();
l_inline_part = new MimeBodyPart ();
l_inline_part.setDisposition (Part.INLINE);
l_inline_part.setText (p_message,l_encoding);
l_mimemultipart.addBodyPart (l_inline_part);
l_inline_part.setHeader ("Content-Type","text/html;charset="UTF-8"");
l_smtp_message.setSentDate(new java.util.Date());
l_smtp_message.setSubject (MimeUtility.encodeText(p_subject,l_encoding,"B"));
l_smtp_message.setContent (l_mimemultipart);
l_smtp_message.saveChanges();
smtpTransport.sendMessage (l_smtp_message,l_smtp_message.getAllRecipients());
Any idea what I am doing wrong. Once again with authentication and no authentication, I keep getting this same error.
Regards,
Priyam