From 8956e7566e2bdc80ecbfdabe9c38bfe05d3e124b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Dec 2017 12:14:48 +0300 Subject: using SMTP transport --- juick-api/src/main/java/com/juick/api/EmailManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'juick-api/src/main/java') diff --git a/juick-api/src/main/java/com/juick/api/EmailManager.java b/juick-api/src/main/java/com/juick/api/EmailManager.java index edf7c000..c0cc1c37 100644 --- a/juick-api/src/main/java/com/juick/api/EmailManager.java +++ b/juick-api/src/main/java/com/juick/api/EmailManager.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import javax.inject.Inject; import javax.mail.MessagingException; +import javax.mail.NoSuchProviderException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; @@ -48,6 +49,7 @@ public class EmailManager implements ApplicationListener { prop.put("mail.smtp.starttls.enable", "true"); Session session = Session.getDefaultInstance(prop); try { + Transport transport = session.getTransport("smtp"); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("juick@juick.com")); message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(email)); @@ -55,7 +57,7 @@ public class EmailManager implements ApplicationListener { message.setText(String.format("%s\n%s\n---\nYou are receiving this because you are subscribed to this user " + "or discussion. Configure notifications at https://juick.com/settings", formatPost(msg), formatUrl(msg))); - Transport.send(message); + transport.send(message); } catch (MessagingException ex) { logger.error("mail exception", ex); } -- cgit v1.2.3