Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-1935

Avoiding problems with SMTP

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.8
    • Fix Version/s: 10.4.11, 10.5
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              srosse Stéphane Rossé
              Reporter:
              stephan Stephan Clemenz
              Tester:
              Stephan Clemenz
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 40 minutes
                1h 40m