Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.net.ssl.SSLException when sending mail using JavaMail

Tags:

javax.mail.MessagingException: Exception reading response;   nested exception is:         javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764)         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1523)         at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)         at javax.mail.Service.connect(Service.java:313)         at javax.mail.Service.connect(Service.java:172)         at javax.mail.Service.connect(Service.java:121)         at javax.mail.Transport.send0(Transport.java:190)         at javax.mail.Transport.send(Transport.java:120)         at javaapplication5.SendMail.send(SendMail.java:77)         at javaapplication5.SendMailTest.main(SendMailTest.java:17) Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?         at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:523)         at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:355)         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:789)         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:744)         at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)         at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:106)         at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)         at java.io.BufferedInputStream.read(BufferedInputStream.java:237)         at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:84)         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1742)         ... 9 more 

Can anybody help me to send a mail using JavaMail API using proxy?

like image 552
Rajesh Kumar J Avatar asked Jul 21 '09 06:07

Rajesh Kumar J


People also ask

How can I get SMTP server response using JavaMail?

SMTPTransport t = (SMTPTransport)session. getTransport("smtps"); t. send(message); String response = t. getLastServerResponse(); boolean s = t.

What is mail SMTP Starttls enable?

smtp. starttls. enable, to "true". When set, if the server supports the STARTTLS command, it will be used after making the connection and before sending any login information.

Which protocol is used to receive the messages in JavaMail?

IMAP: Acronym for Internet Message Access Protocol. It is an advanced protocol for receiving messages. It provides support for multiple mailbox for each user, in addition to, mailbox can be shared by multiple users. It is defined in RFC 2060.


1 Answers

You are trying to do an SSL connection to a non-SSL port. This will not work.

If you want to send mail through gmail, see the FAQ: http://java.sun.com/products/javamail/FAQ.html#gmail

like image 58
Thorbjørn Ravn Andersen Avatar answered Sep 20 '22 05:09

Thorbjørn Ravn Andersen