Skip to content

[5.4] Inconsistent envelope from in MailerFactory vs Mail class #46419

@TLWebdesign

Description

@TLWebdesign

Steps to reproduce the issue

Send an e-mail with the default Mailer instance. Return Path and envelope-from are not aligned with "From" e-mail header. I noticed this when i was using MailTemplate to send e-mails without passing a custom Mailer to the MailTemplate.
It produces headers like this:

Return-Path: <[email protected]>
    (envelope-from <[email protected]>)
From: Example Name <[email protected]>

But when i do a $mailer->setSender() and then pass that to the MailTemplate, It produces these e-mail headers:

Return-Path: <[email protected]>
(envelope-from <[email protected]>)
From: Example Name <[email protected]>

This improves e-mail deliverability because now these domains are aligned with the SPF and the DKIM records. Where before they were not.

Expected result

E-mail header domains aligned

Actual result

E-mail header domains not aligned.

Additional comments

I think the root cause is this line:

if ($mailer->setFrom($mailfrom, MailHelper::cleanLine($fromname), false) === false) {
where we set the default true (3rd param) to false.

Where as in the Mail class we don't do this:

$result = $this->setFrom(MailHelper::cleanLine($from[0]), MailHelper::cleanLine($from[1]));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions