Update CMailFile.class.php

This commit is contained in:
Laurent Destailleur 2020-07-06 12:00:14 +02:00 committed by GitHub
parent cb7b66d52c
commit 2f04b4c559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -396,13 +396,12 @@ class CMailFile
//$this->message->setFrom(array('john@doe.com' => 'John Doe')); //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
if (! empty($from)) { if (! empty($from)) {
try { try {
if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
// Prevent email spoofing for smtp server with a strict configuration // Prevent email spoofing for smtp server with a strict configuration
$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom); $emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
$adressEmailFrom = reset($adressEmailFrom); $adressEmailFrom = reset($adressEmailFrom);
if($emailMatchs !== false if($emailMatchs !== false
&& $conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING
&& filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL)
&& $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom) && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom)
{ {
@ -412,6 +411,9 @@ class CMailFile
{ {
$result = $this->message->setFrom($this->getArrayAddress($from)); $result = $this->message->setFrom($this->getArrayAddress($from));
} }
} else {
$result = $this->message->setFrom($this->getArrayAddress($from));
}
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }