java - SMTP not getting connected -


here java code send email, whenever run code shows javax.mail.messagingexception: not connect smtp host: ipaddress, port: 25; tried changing port number, still same error.. can me.. (i have included mail.jar , activation.jar project)

public static void main(string arfs[]) throws unknownhostexception {     inetaddress address = inetaddress.getlocalhost();                   string to="gggg@gmail.com";                 string from="vvvvv@gmail.com";                 string host=address.gethostaddress();                  properties properties = system.getproperties();                   properties.setproperty("mail.smtp.host",host);                 properties.setproperty("mail.smtp.port", "25");                 session session = session.getdefaultinstance(properties);                    try{                        mimemessage message = new mimemessage(session);                        message.setfrom(new internetaddress("vvvv@gmail.com"));                        message.addrecipient(message.recipienttype.to,new internetaddress("ggggg@gmail.com"));                        message.setsubject("test email");                        message.settext("hello");                        transport.send(message);                        system.out.println("message sent successfully....");                        }                 catch(messagingexception mex)                 {                     mex.printstacktrace();                 }          } 

check whether system has smtp access?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -