email - I have this code to send mail from java showing error -


      package controller;        import java.util.properties;       import javax.mail.*;       import javax.mail.internet.internetaddress;       import javax.mail.internet.mimemessage;       public class sendmail {       static string = "******@gmail.com";      static string pass ="*****";      static string = "****@gmail.com";      static string host = "smtp.gmail.com";       public static void main(string[] args) {           properties properties = system.getproperties();           properties.put("mail.smtp.starttls.enable", "true");           properties.put("mail.smtp.host", host);           properties.put("mail.smtp.user", from);           properties.put("mail.smtp.password", pass);           properties.put("mail.smtp.port", "587");           properties.put("mail.smtp.auth", "true");           session session = session.getdefaultinstance(properties);            try{       mimemessage message = new mimemessage(session);         message.setfrom(new internetaddress(from));         message.addrecipient(message.recipienttype.to,                                new internetaddress(to));         message.setsubject("this subject line!");         message.settext("ithis test");         transport transport = session.gettransport("smtp");       transport.connect(host, from, pass);       transport.sendmessage(message, message.getallrecipients());       transport.close();       system.out.println("sent message successfully....");    }        catch (messagingexception mex) {          mex.printstacktrace();         }         }     } 

this code shows error of: javax.mail.messagingexception: not convert socket tls; me, why can't convert socket tls. can resolve error?? please help.

by default, gmail not allow "less-secure" apps access email.

in order code run:


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -