spring - How to email in Java? -
please solution on how send email in java. contains message body, subject, etc. single simple solution beneficial. thanks
better have 1 method email purpose , call ever u need passing arguments in each method u need.
public string sendmail(string message, string subject, string recipientaddress, httpsession session) { system.out.println("to:" + recipientaddress); system.out.println("subject:" + subject); system.out.println("message:" + message); try { simplemailmessage email = new simplemailmessage(); email.setto(recipientaddress); email.setsubject(subject); email.settext(message); mailsender.send(email); } catch (mailexception e) { system.out.println("mail not sent...!" + e); return "noemail"; } return "success"; }
Comments
Post a Comment