/* @param fromMail Send mailbox * @param user email account * @param password email password * @param toMail receive email * @param mailTitle message headers * @param mailContent Email * @throws Exception */ public static void SendMail (String frommail, string user, string password, string tomail, string mailtitle, string mailcontent) throws Exception { mailsslsocketfactory sf = new mailsslsocketfactory (); sf.settrustallhosts (True); properties prOps = new properties (); props.put (" Mail.smtp.host ", " mail.*****.com "); props.put (" Mail.smtp.port ", 465); props.put (" Mail.transport.protocol " , "SMTP"); props.put ("Mail.smtp.auth", "true"); props.put ("mail.smtp.ssl.enable", "true"); props.put ("Mail.smtp.ssl.socketFactory",  SF); session session = session.getinstance (props); mimemessage message = new mimemessage (session); message.setfrom (New internetaddress (frommail)); message.setrecipient (MessaGe. Recipienttype.to, new internetaddress (tomail)); Message.setsubject (Mailtitle); message.settext (mailContent); message.setsentdate (New date ()); message.savechanges (); transport Transport = session.gettransport (); transport.connect (User, password); transport.sendmessage (message, Message.getallrecipients ()); transport.close (); }
Here are the packages you need to add:
<dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <versio N>1.4.7</version></dependency>
Javax.mail sending mail