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: <user1@srv1.example.nl>
(envelope-from <user1@srv1.example.nl>)
From: Example Name <noreply@domain.nl>
But when i do a $mailer->setSender() and then pass that to the MailTemplate, It produces these e-mail headers:
Return-Path: <noreply@domain.nl>
(envelope-from <noreply@domain.nl>)
From: Example Name <noreply@domain.nl>
This improves e-mail deliverability because now these domains are aligned with the SPF and the DKIM records. Where before they were not.
E-mail header domains aligned
E-mail header domains not aligned.
I think the root cause is this line:
Where as in the Mail class we don't do this:
joomla-cms/libraries/src/Mail/Mail.php
Line 205 in 813bfe8
| Labels |
Added:
No Code Attached Yet
|
||
| Title |
|
||||||
This code was more or less copied from the j3 factory equivalent. Pretty sure there was no specific reason.
Hi, ah ok thanks for letting me know 😄 i'll create a PR for this.
Can you please share the code you use. It is not very clear what exactly you doing.
Side note: I doubt we can change the behavior, as it may break many many existing sites.
Hi @Fedik,
It is a direct copy form the code from this user -> joomla plugin here:
$mailer = new MailTemplate('plg_user_joomla.mail', $userLocale);
$mailer->addTemplateData($data);
$mailer->addUnsafeTags(['username', 'password', 'name', 'email']);
$mailer->addRecipient($user['email'], $user['name']);
See now the MailTemplate is not being passed a Mailer instance so it relies on the default mailer where the 3rd flag for setSender defaults to "false". Why i don't know, because even in phpMailer itself this flag defaults to true (as it should).
So my suggestion is to also have Joomla default this to true because it benefits e-mail deliverability across the board.
I am curious tho how improving the envelope from would cause existing sites to break?
Okay. Yeah, maybe it not that much b/c break as I thought.
You can send a PR and we will discuss further.
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-11-10 12:29:32 |
| Closed_By | ⇒ | richard67 |
@laoneo i see you did the MailerFactory.php is there a specific reason why you chose to set the auto param (3rd one) to false? Maybe i'm overlooking something why it is set to false.