• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending mail through Java

 
Yashwant Palkar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using following code to send mail through java application




its giving me an error 530 5.7.1 Client was not authenticated
DEBUG SMTP: got response code 530, with response: 530 5.7.1 Client was not authenticated


Please help me to solve this issue..

Thanks,
Yashwant
 
Alpesh Gediya
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yashwant,

I would sugget you to put java code in Code block.

Go through following link. follow steps mentioned

http://smtp25.blogspot.com/2009/04/530-571-client-was-not-authenticated.html

before that i suggest you to use your mail account credential i.e. smtp username and password.
 
Rob Spoor
Sheriff
Pie
Posts: 20398
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags next time. I've added them for you this time.

Yashwant Palkar wrote:its giving me an error 530 5.7.1 Client was not authenticated
DEBUG SMTP: got response code 530, with response: 530 5.7.1 Client was not authenticated

It seems you need to login to use this SMTP server.

Try sending like this, instead of using Transport.send(msg):
 
Yashwant Palkar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this methods are not available which API you are using.
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the same JavaMail API you're already using. If you're serious about using it, start by working through a thorough tutorial like http://java.sun.com/developer/onlineTraining/JavaMail/contents.html
 
Rob Spoor
Sheriff
Pie
Posts: 20398
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JEE.
Message.saveChanges()
Session.getTransport(String)
Service.connect(String, String, String) (Transport extends Service)
Transport.sendMessage(Message, Address[]) (scroll down; the Address[] won't let me create a direct URL) with Message.getAllRecipients()
Service.close()
 
Yashwant Palkar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
DEBUG SMTP: mechanism LOGIN not supported by server
DEBUG SMTP: mechanism PLAIN not supported by server
DEBUG SMTP: mechanism DIGEST-MD5 not supported by server
java.lang.ClassNotFoundException: jcifs.ntlmssp.Type1Message
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sonicsw.mf.framework.agent.ClassLoaderFactory$DelegateLoader.loadClass(ClassLoaderFactory.java:595)
at com.sonicsw.mf.framework.agent.ClassLoaderFactory$DelegateLoader.loadClass(ClassLoaderFactory.java:553)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.mail.auth.Ntlm.generateType1Msg(Ntlm.java:65)
at com.sun.mail.smtp.SMTPTransport$NtlmAuthenticator.getInitialResponse(SMTPTransport.java:784)
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:623)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)


I am getting this error while using this code.
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't know what "this code" is, but jCIFS is not part of JavaMail or JEE, so it must be used by some other component, possibly the "com.sonicsw.mf.framework" stuff. It has in any case nothing to do with JavaMail.

I advise to get the mail part working as a standalone application -like you did at first- before trying to integrate it elsewhere.
 
Yashwant Palkar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried it with simple java code.
still giving same error

This is log I am getting from code.

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
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: use8bit false
MAIL FROM:<yashwant.palkar@xxx.com>
530 5.7.1 Client was not authenticated
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.1 Client was not authenticated

com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.1 Client was not authenticated

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at TestEMail.main(TestEMail.java:46)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at TestEMail.main(TestEMail.java:46)
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the code that performs the authentication; is it being called?
 
Paul Clapham
Sheriff
Pie
Posts: 20208
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lester Burnham wrote:We don't know what "this code" is, but jCIFS is not part of JavaMail or JEE, so it must be used by some other component, possibly the "com.sonicsw.mf.framework" stuff. It has in any case nothing to do with JavaMail.


I think that's not correct. I believe that recent versions of JavaMail have attempted to include NTLM authentication, and for that they simply used jCIFS to do the authentication. I don't know whether that resulted in a requirement to include jCIFS as a dependency or whether it was somehow included directly in the mail.jar, I'm just saying this based on answers I remember seeing on other forums which were posted by the author of JavaMail.
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stand corrected: JavaMail doesn't ship with jCIFS, but it can make use of it for NTLM authentication. That's documented in the NTLMNOTES.txt file in the JavaMail distribution.
 
Paul Clapham
Sheriff
Pie
Posts: 20208
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha. Thanks for doing the research, Lester.
 
M Massa
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try something like this:



Where SMTPAuthenticator is defined as:

 
Yashwant Palkar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried through Authenticator but getting same error.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic