diff options
Diffstat (limited to 'juick-api')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/EmailManager.java | 4 |
1 files changed, 3 insertions, 1 deletions
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<MessageEvent> { 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<MessageEvent> { 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); } |