From eda320df70c204fed7cbfb3b356b9c65b38db397 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Dec 2017 14:25:39 +0300 Subject: transport connect --- juick-api/src/main/java/com/juick/api/EmailManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 1573e7be..2c48a745 100644 --- a/juick-api/src/main/java/com/juick/api/EmailManager.java +++ b/juick-api/src/main/java/com/juick/api/EmailManager.java @@ -56,13 +56,20 @@ public class EmailManager implements ApplicationListener { Session session = Session.getDefaultInstance(prop); try { Transport transport = session.getTransport("smtp"); - MimeMessage message = new MimeMessage(session); + MimeMessage message = new MimeMessage(session) { + protected void updateMessageID() throws MessagingException { + if (getHeader("Message-ID") == null) + super.updateMessageID(); + } + }; message.setFrom(new InternetAddress("juick@juick.com")); message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(email)); message.setSubject(subject); 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))); + message.saveChanges(); + transport.connect(); transport.sendMessage(message, message.getAllRecipients()); } catch (MessagingException ex) { logger.error("mail exception", ex); -- cgit v1.2.3