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:
- ...someactions...
- Call email_to_user from moodlelib.php
- 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; } - 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))
}
- email_to_user perfrom any actions ...
- email_to_user call $mail->send()
- send in class.phpmailer.php in order calls $this->preSend() and $this->postSend()
- postSend call $this->smtpSend
- 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; } - 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