• Register
0 votes
742 views

Problem :

I have a java complied package and it is sopposed to communicate with https server on net. But when i try running the compilation gives the following exception:

javax.net.ssl.sslexception: unrecognized ssl message, plaintext connection?

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had the similar issue but its working for me now, I have changed the setting of my google account by running bellow code: 

System.out.println("Start"); 

final String username = "myemail@gmail.com"; 

final String password = "************"; 

Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "465"); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 

Session session = Session.getInstance(props, new javax.mail.Authenticator() 

protected PasswordAuthentication getPasswordAuthentication()

 { 

return new PasswordAuthentication(username, password); 

}

); 

try { 

Transport transport=session.getTransport(); 

Message message = new MimeMessage(session); message.setFrom(new InternetAddress("myemail@gmail.com"));

//formBean.getString("fromEmail") message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("myemail@gmail.com")); message.setSubject("subject");

//formBean.getString( message.setText("mailBody"); transport.connect(); transport.send(message, InternetAddress.parse("myemail@gmail.com"));

//(message); 

System.out.println("Done");

 } 

catch (MessagingException e) 

System.out.println("e="+e); 

e.printStackTrace(); 

throw new RuntimeException(e); 

}

  • Disable the 2-step verification (password and OTP)

  • Enabling to allow to access less secure app(Allow less secure apps: ON.)

Now you will be able to send mail using above program.

Further Readings:

https://github.com/nctoolbox/nctoolbox/issues/94

9 7 4
38,600 points

Related questions

0 votes
1 answer 2 views
2 views
Problem: I have a java complied package to speak with the https server on net. Running the compilation gives the following exception: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown ... secure. Is there any way to configure the local machine or ports in order to connect to the remote https server?
asked Apr 25 Humaira ahmed 50.7k points
1 vote
1 answer 8 views
8 views
Problem: Any ideas on what I need to do to fix this? unrecognized ssl message, plaintext connection?
asked Mar 15 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 5 views
5 views
Problem: Have anyone had this drawback before >Javax.net.ssl.sslexception: received fatal alert: unknown_ca
asked 4 days ago Sawyer Parviz 13.2k points
0 votes
1 answer 5 views
5 views
Problem: I have a Java application, from which I am trying to connect to a https url but having issues with SSL ending up with the error: Received fatal alert: bad_record_mac (javax.net.ssl.SSLException)How can I go about further debugging this issue?
asked May 4 Moumita Bhowmick 12.9k points
0 votes
1 answer 477 views
477 views
Problem : I am trying to call an SSL protected web service running on JDK7 based client, but getting bellow error javax.net.ssl.sslexception received fatal alert unexpected_message
asked Nov 5, 2019 peterlaw 6.9k points
0 votes
2 answers 502 views
502 views
Problem : Has anyone faced this error before? I am new to SSL javax.net.ssl.sslexception: received fatal alert: protocol_version
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
1 answer 6 views
6 views
Problem: Why I got the error > Javax.net.ssl.sslhandshakeexception: remote host closed connection during handshake
asked Apr 25 ummeshani 10.8k points
0 votes
1 answer 10 views
10 views
Problem: I have configured a ListenHTTP 1.7.0 processor in NiFi 1.7.0-RC1. It is listening on a custom port behind a reverse proxy. I have configured a StandardRestrictedSSLContextService with a JKS keystore and have added the keystore password. We have not configured ... support a common SSL protocol version or cipher suite. Can anyone suggest what to try next or explain why we see this error?
asked Apr 25 sumaiya simi 43.9k points
0 votes
1 answer 341 views
341 views
Problem: I am trying to consume a PHP webservice which has the SSL certificate. I have the .net 3.5 Class library it references the webservice with a 'Add Service references' in Visualstudio 2010 If I try calling the main method of my webservice then I ... SslPolicyErrors sslPolicyErrors) { return true; } But somehow it is not working. Also I have already a certificate installed on my own pc.
asked Aug 12, 2020 Raphael Pacheco 4.9k points