Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56224

If you have techsupport and noreply emails on different services and setup sent only from noreply, you encounter a problem when moodle try send email from techsupport over noreply service via smtp.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.1.1
    • Email
    • MOODLE_31_STABLE

      Hello.

      Imagine this situation:
      techsupport email: th@service*1*
      noreply email: nr@service*2*;
      smtp: smtp.service*2*;
      Sent always from noreply: yes
      Mailer: smtp;

      And user try to register with email or reset own password and moodle try to sent him message. But message doesn't sent, because smtp.service2 doesn't exit user with email th@service1

      In detail:

      1. ...someactions...
      2. Call email_to_user from moodlelib.php
      3. email_to_user set $mail->Sender if not empty $CFG->handlebounces autogenerated email, if empty get value from techsupport email (th@service1).
        Source code:
        // Make up an email address for handling bounces.
        if (!empty($CFG->handlebounces)) { $modargs = 'B'.base64_encode(pack('V', $user->id)).substr(md5($user->email), 0, 16); $mail->Sender = generate_email_processing_address(0, $modargs); }

        else

        { $mail->Sender = $supportuser->email; }
      4. Then if set $CFG->emailonlyfromnoreplyaddress mark flag usetrueaddress to false and then use for From noreply address. And mark support email as replyto. Code:
        if (!empty($CFG->emailonlyfromnoreplyaddress))
        Unknown macro: { $usetrueaddress = false; if (empty($replyto) && $from->maildisplay) { //Memory reply to, for set later ... $replyto = $from->email; $replytoname = fullname($from); } }

      if (is_string($from))

      { // So we can pass whatever we want if there is need. $mail->From = $CFG->noreplyaddress; $mail->FromName = $from; }

      else if ($usetrueaddress and $from->maildisplay)

      { $mail->From = $from->email; $mail->FromName = fullname($from); }

      else {
      //In this point in From set correct noreply address
      $mail->From = $CFG->noreplyaddress;
      $mail->FromName = fullname($from);
      if (empty($replyto))

      { $tempreplyto[] = array($CFG->noreplyaddress, get_string('noreplyname')); }

      }

      1. email_to_user perfrom any actions ...
      2. email_to_user call $mail->send()
      3. send in class.phpmailer.php in order calls $this->preSend() and $this->postSend()
      4. postSend call $this->smtpSend
      5. smtpSend after some actions check Sender to empty string, if Sender not empty that memory Sender to smtp_from else use From. Code:
        if ('' == $this->Sender) { $smtp_from = $this->From; }

        else

        { $smtp_from = $this->Sender; }
      6. And than send mail with smtp_from as sender!!! But in smtp_from contains th@service1, but smtp user server smtp.service2 !!! Code: $this->smtp->mail($smtp_from)

      Why in email_to_user sets forcibly tech support email to Sender, if in settings setup sent mails only from noreply email and tech support email correct sets in reply to?

      Thanks,
      Artem Matveev

      Thanks

            Unassigned Unassigned
            21a1ss3 Artem Matveev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.