* Mail: prefer identity email over SMTP username for Return-Path header, if both are from the same domain

This commit is contained in:
ralf 2025-01-11 11:03:26 +01:00
parent 5aef3df2e8
commit 5207095b7d

View File

@ -144,8 +144,10 @@ class Mailer extends Horde_Mime_Mail
}
// use smpt-username as sender/return-path, if available, but only if it is a full email address
$sender = $this->account->acc_smtp_username && strpos($this->account->acc_smtp_username, '@') !== false ?
$this->account->acc_smtp_username : $identity['ident_email'];
$sender = $this->account->acc_smtp_username && strpos($this->account->acc_smtp_username, '@') === false ||
// if both are from the same domain, prefer the identity email over the smtp-username
explode('@', $identity['ident_email'])[1] === explode('@', $this->account->acc_smtp_username)[1] ?
$identity['ident_email'] : $this->account->acc_smtp_username;
$this->addHeader('Return-Path', '<'.$sender.'>', true);
$this->setFrom($identity['ident_email'], $identity['ident_realname']);