From 0dc478ac0035a0a356e161fce35bb8a1aaefd7a3 Mon Sep 17 00:00:00 2001 From: fusionate Date: Wed, 2 Dec 2020 12:20:10 -0700 Subject: [PATCH] Fax Server: Add ability to authorize domains for Email-to-Fax. --- app/fax/app_languages.php | 4 ++-- app/fax/fax_edit.php | 4 +++- app/fax/fax_emails.php | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 914cc3685d..2f5e22804c 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -3214,8 +3214,8 @@ $text['description-email_outbound_subject_tag']['ru-ru'] = "Установите $text['description-email_outbound_subject_tag']['sv-se'] = "Ange E-post ämne för utgående fax."; $text['description-email_outbound_subject_tag']['uk-ua'] = ""; -$text['description-email_outbound_authorized_senders']['en-us'] = "Define the email address(es) allowed to send faxes through this server."; -$text['description-email_outbound_authorized_senders']['en-gb'] = "Define the email address(es) allowed to send faxes through this server."; +$text['description-email_outbound_authorized_senders']['en-us'] = "Define the email address(es) and/or domains allowed to send faxes through this server."; +$text['description-email_outbound_authorized_senders']['en-gb'] = "Define the email address(es) and/or domains allowed to send faxes through this server."; $text['description-email_outbound_authorized_senders']['ar-eg'] = ""; $text['description-email_outbound_authorized_senders']['de-at'] = "Geben Sie die Email Addresse(n) an, von welchen Faxe gesendet werden dürfen."; //copied from de-de $text['description-email_outbound_authorized_senders']['de-ch'] = "Geben Sie die Email Addresse(n) an, von welchen Faxe gesendet werden dürfen."; //copied from de-de diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php index 6961f147e6..ae11e2bdc1 100644 --- a/app/fax/fax_edit.php +++ b/app/fax/fax_edit.php @@ -278,7 +278,9 @@ //prep authorized senders if (sizeof($fax_email_outbound_authorized_senders) > 0) { foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) { - if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); } + if ($sender == '' || (substr_count($sender, '@') == 1 && !valid_email($sender)) || substr_count($sender, '.') == 0) { + unset($fax_email_outbound_authorized_senders[$sender_num]); + } } $fax_email_outbound_authorized_senders = strtolower(implode(',', $fax_email_outbound_authorized_senders)); } diff --git a/app/fax/fax_emails.php b/app/fax/fax_emails.php index 943e6516b4..d39859eff3 100644 --- a/app/fax/fax_emails.php +++ b/app/fax/fax_emails.php @@ -170,9 +170,9 @@ if (is_array($result) && @sizeof($result) != 0) { $metadata[0]['from'] = strtolower($tmp[0]['mailbox']."@".$tmp[0]['host']); //check sender - $sender_authorized = false; - if (in_array($metadata[0]['from'],$authorized_senders)) { $sender_authorized = true; } - + $sender_email = $metadata[0]['from']; + $sender_domain = explode('@', $sender_email)[1]; + $sender_authorized = in_array($sender_email, $authorized_senders) || in_array($sender_domain, $authorized_senders) ? true : false; if ($sender_authorized) { //add multi-lingual support