From address always added to Reply-To even if Reply-To is set

Created on 21 February 2023, almost 2 years ago

The From address is being added to Reply-To if the 'from' parameter is in the parameter array before the Reply-To, regardless of a Reply-To being set. This can cause issues with clients that reject multiple addresses in the Reply-To, in addition to having the wrong Reply-To.

I believe this is due to the function SetFrom in smtp.phpmailer.inc auto-populating the Reply-To. It looks like the code in smtp.mail.inc also attempts to do this on line 145, which should be enough.

I don't have the means to submit a patch, but our solution was to change the call on line 197 in smtp.mail.inc from $mailer->setFrom($from, $from_name); to $mailer->setFrom($from, $from_name, 0); and this fixed our issue.

πŸ› Bug report
Status

Active

Version

1.9

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ramzypro

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ramzypro
  • πŸ‡ΊπŸ‡ΈUnited States ramzypro
  • πŸ‡¦πŸ‡«Afghanistan mustardman

    I am also having this problem. Will try that suggested fix.

  • πŸ‡¨πŸ‡¦Canada johnjw59@gmail.com

    Yup, this is an issue!

    I think we should keep the call to $mailer->setFrom() as-is though; if a Reply-To header is not present, the default should be whatever the "From" address is. Therefore, my proposed solution is to just clear out any set Reply-To headers before we explicitly add them. Patch doing just that is attached.

  • πŸ‡ΊπŸ‡ΈUnited States ramzypro

    We replaced what we did with the patch in #4 and the issue has not returned. I can confirm the patch works.

  • Status changed to RTBC about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 7.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    6 pass
  • πŸ‡ΊπŸ‡ΈUnited States steveganz

    We've had the patch in #4 deployed in our production environment for the last 30 days, sending thousands of emails each week successfully with Reply-To header sets correctly.

  • πŸ‡ΊπŸ‡ΈUnited States jenlampton

    This almost worked for me, but I had multiple reply-tos. I was able to duplicate similar code used for cc, bcc, and to, that handles multiple addresses, in addition to adding this change.

          case 'reply-to':
              $mailer->ClearReplyTos();
              $rtrecipients = explode(',', $value);
              foreach ($rtrecipients as $rtrecipient) {
                $replyto_comp = $this->_get_components($rtrecipient);
                $mailer->AddReplyTo($replyto_comp['email'], $replyto_comp['name']);
              }
              break;
    
Production build 0.71.5 2024