aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-25 12:14:48 +0300
committerGravatar Vitaly Takmazov2017-12-25 12:14:48 +0300
commit8956e7566e2bdc80ecbfdabe9c38bfe05d3e124b (patch)
treeb75767af942a52e42798a567dd8b85aedf052584 /juick-api/src
parente8ffd4497af18b22519c94f1b22c32ddf3d446f0 (diff)
using SMTP transport
Diffstat (limited to 'juick-api/src')
-rw-r--r--juick-api/src/main/java/com/juick/api/EmailManager.java4
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);
}