i trying send email forgotpassword using smtp.but getting exception below
javax.mail.sendfailedexception: sending failed; nested exception is: class javax.mail.messagingexception: not connect smtp host: localhost, port: 25;
the below java code
string = email; string = "xxxxxxx@gmail.com"; string host = "localhost"; properties properties = system.getproperties(); properties.setproperty("mail.smtp.host", host); 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.setcontent("<h1>this actual message</h1>", "text/html"); transport.send(message); }
can 1 please tell me how can send email using smtp
Comments
Post a Comment