-
Type:
Improvement
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 10.4.8
-
Component/s: None
-
Labels:None
-
Funded by:
In the last weeks we noticed that the delivery of certain mails is refused by some incoming mail servers. They determine that the domain of the outgoing mail server is not the same domain as the senders address. Checking the maillog, the from-address of the outgoing mail is not the same as given in olat.local.properties (in our case lms-admin@vcrp.de). It's the senders address:
Mar 14 12:13:21 olat-dev sendmail[18485]: u2EBDKWT018485: from=<stud4@vcrp.de>, size=1638, class=0, nrcpts=2, msgid=<2054020907.2.1457954000917.JavaMail.eclipse@olat-dev.vcrp.de>, proto=ESMTP, daemon=MTA, relay=olat-dev.vcrp.de [127.0.0.1]
The message header is okay:
From: lms-admin@vcrp.de Reply-To: stud4@vcrp.de
But the SMTP envelope is not right. The envelope-from must be explicitly set. I solved the problem by following patch:
diff --git a/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java b/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java --- a/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java +++ b/src/main/java/org/olat/core/util/mail/manager/MailManagerImpl.java @@ -110,6 +110,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.sun.mail.smtp.SMTPMessage; + /** * * Description:<br> @@ -1598,6 +1600,11 @@ @Override public void sendMessage(MimeMessage msg, MailerResult result){ + SMTPMessage smtpMsg = null; + try { + smtpMsg = new SMTPMessage(msg); + smtpMsg.setEnvelopeFrom(WebappHelper.getMailConfig("mailFrom")); + } catch (MessagingException e) {} try{ if(Settings.isJUnitTest()) { //we want not send really e-mails @@ -1611,7 +1618,10 @@ log.error("", e); } } - Transport.send(msg); + if (smtpMsg == null) + Transport.send(msg); + else + Transport.send(smtpMsg); } else if(Settings.isDebuging() && result.getReturnCode() == MailerResult.OK) { try { log.info("E-mail send: " + msg.getSubject());
maillog shows:
Mar 14 13:26:12 olat-dev sendmail[19509]: u2ECQCWJ019509: from=<lms-admin@vcrp.de>, size=1611, class=0, nrcpts=2, msgid=<489259934.2.1457958372671.JavaMail.eclipse@olat-dev.vcrp.de>, proto=ESMTP, daemon=MTA, relay=olat-dev.vcrp.de [127.0.0.1]
which is correct.