java - Could Not convert socket to TLS -
i trying send email using java servlets in eclipse ide. code.
final string username = "******@gmail.com"; final string password = "******"; properties props = new properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.ssl.trust", "smtpserver"); session session1 = session.getinstance(props, new javax.mail.authenticator() { protected passwordauthentication getpasswordauthentication() { return new passwordauthentication(username, password); } }); try { if(result) { message message = new mimemessage(session1); message.setfrom(new internetaddress("******60@gmail.com")); message.setrecipients(message.recipienttype.to, internetaddress.parse(email)); message.setsubject("welcome our bank"); message.settext("dear "+custname+"," +"\n\n account has been created successfully." +"\n\n account details are:" +"\n user id : "+userid+"" +"\n account number : "+accno+"" +"\n login password : "+passwd+"" +"\n transaction password : "+t_passwd+""); transport.send(message); out.println("mail sent"); } } catch(messagingexception e) { out.println("exception caught : "+e); }
this exception occur after execution.
exception caught : javax.mail.messagingexception: not convert socket tls; nested exception is: java.io.ioexception: server not trusted: smtp.gmail.com
by setting "mail.smtp.ssl.trust" "smtpserver" you've said trust server named "smtpserver". "smtp.gmail.com" not named "smtpserver".
Comments
Post a Comment