From dcaff3f7de64de6257ffd84aef196f6fd9a0403b Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 3 Dec 2024 15:00:11 +0100 Subject: [PATCH] set sender-address of emails which were sent using an admin/a reseller to the global settings email so sending it using provided smtp settings will not fail antispam checks; fixes #1289 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/EmailAccounts.php | 8 ++++++-- lib/Froxlor/Cron/Traffic/ReportsCron.php | 8 ++++++-- lib/Froxlor/System/Mailer.php | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Froxlor/Api/Commands/EmailAccounts.php b/lib/Froxlor/Api/Commands/EmailAccounts.php index df7f73ca..707a816d 100644 --- a/lib/Froxlor/Api/Commands/EmailAccounts.php +++ b/lib/Froxlor/Api/Commands/EmailAccounts.php @@ -260,7 +260,9 @@ class EmailAccounts extends ApiCommand implements ResourceEntity $_mailerror = false; $mailerr_msg = ""; try { - $this->mailer()->setFrom($admin['email'], User::getCorrectUserSalutation($admin)); + $this->mailer()->setFrom(Settings::Get('panel.adminmail'), User::getCorrectUserSalutation($admin)); + $this->mailer()->clearReplyTos(); + $this->mailer()->addReplyTo($admin['email'], User::getCorrectUserSalutation($admin)); $this->mailer()->Subject = $mail_subject; $this->mailer()->AltBody = $mail_body; $this->mailer()->msgHTML(str_replace("\n", "
", $mail_body)); @@ -290,7 +292,9 @@ class EmailAccounts extends ApiCommand implements ResourceEntity $_mailerror = false; try { - $this->mailer()->setFrom($admin['email'], User::getCorrectUserSalutation($admin)); + $this->mailer()->setFrom(Settings::Get('panel.adminmail'), User::getCorrectUserSalutation($admin)); + $this->mailer()->clearReplyTos(); + $this->mailer()->addReplyTo($admin['email'], User::getCorrectUserSalutation($admin)); $this->mailer()->Subject = $mail_subject; $this->mailer()->AltBody = $mail_body; $this->mailer()->msgHTML(str_replace("\n", "
", $mail_body)); diff --git a/lib/Froxlor/Cron/Traffic/ReportsCron.php b/lib/Froxlor/Cron/Traffic/ReportsCron.php index 4a124b89..690e6d2e 100644 --- a/lib/Froxlor/Cron/Traffic/ReportsCron.php +++ b/lib/Froxlor/Cron/Traffic/ReportsCron.php @@ -133,7 +133,9 @@ class ReportsCron extends FroxlorCron $_mailerror = false; $mailerr_msg = ""; try { - $mail->SetFrom($row['adminmail'], $row['adminname']); + $mail->setFrom(Settings::Get('panel.adminmail'), $row['adminname']); + $mail->clearReplyTos(); + $mail->addReplyTo($row['adminmail'], $row['adminname']); $mail->Subject = $mail_subject; $mail->AltBody = $mail_body; $mail->MsgHTML(nl2br($mail_body)); @@ -405,7 +407,9 @@ class ReportsCron extends FroxlorCron $_mailerror = false; $mailerr_msg = ""; try { - $mail->SetFrom($row['adminmail'], $row['adminname']); + $mail->setFrom(Settings::Get('panel.adminmail'), $row['adminname']); + $mail->clearReplyTos(); + $mail->addReplyTo($row['adminmail'], $row['adminname']); $mail->Subject = $mail_subject; $mail->AltBody = $mail_body; $mail->MsgHTML(nl2br($mail_body)); diff --git a/lib/Froxlor/System/Mailer.php b/lib/Froxlor/System/Mailer.php index b8b11cc8..be50f84f 100644 --- a/lib/Froxlor/System/Mailer.php +++ b/lib/Froxlor/System/Mailer.php @@ -68,9 +68,9 @@ class Mailer extends PHPMailer if (self::ValidateAddress(Settings::Get('panel.adminmail')) !== false) { // set return-to address and custom sender-name, see #76 - $this->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); + $this->setFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); if (Settings::Get('panel.adminmail_return') != '') { - $this->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname')); + $this->addReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname')); } } }