Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program to send Email using JavaMail not working.

 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Just trying out the javamail api for fun, am working with the program below:



And I am getting an exception which says:

Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html

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 set1.SimpleMail.main(SimpleMail.java:26)

What am I missing here? Any help will be really appreciated.

Thanks.
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Yahoo grant you smtp access?

it doesn't do for me. I am not allowed to smtp or pop the Yahoo mail severs with my type of Yahoo mail account.

Regards, Jan
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I use gmail instead?
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Turns out only yahoo plus provides this option, and gmail works.
This is the code I used and this version works fine:



This still throws an Exception at the end, although the email is sent. The exception thrown is:

DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: Unsupported record version Unknown-50.49
Exception in thread "main" javax.mail.MessagingException: Exception reading response;
nested exception is:
javax.net.ssl.SSLException: Unsupported record version Unknown-50.49
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1462)
at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:645)
at javax.mail.Transport.send0(Transport.java:171)
at javax.mail.Transport.send(Transport.java:98)
at set1.mail3.sendSSLMessage(mail3.java:69)
at set1.mail3.main(mail3.java:28)
Caused by: javax.net.ssl.SSLException: Unsupported record version Unknown-50.49
at com.sun.net.ssl.internal.ssl.InputRecord.readV3Record(InputRecord.java:363)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:348)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:720)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:677)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440)
... 5 more
 
Bren Zosa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try adding:

props.setProperty("mail.smtp.quitwait", "false");

Found that here: http://forum.java.sun.com/thread.jspa?threadID=5205249&tstart=30
[ August 29, 2007: Message edited by: Bren Zosa ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic