From 51f30e54a8410672eea49817d68dfe2d38b16a21 Mon Sep 17 00:00:00 2001 From: yehudah Date: Mon, 18 Feb 2019 06:22:53 +0000 Subject: = 1.9.8 - 2019-02-18 * New: a new from field to the fallback - Can't trust the username as "from" value (email address). --- .../PostmanConfigurationController.php | 12 ++++++++++++ Postman/Postman-Mail/PostmanMessage.php | 7 +++++++ Postman/PostmanInputSanitizer.php | 1 + Postman/PostmanOptions.php | 15 +++++++++------ 4 files changed, 29 insertions(+), 6 deletions(-) (limited to 'Postman') diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php index 1e5b0a3..bc9c274 100644 --- a/Postman/Postman-Configuration/PostmanConfigurationController.php +++ b/Postman/Postman-Configuration/PostmanConfigurationController.php @@ -301,6 +301,18 @@ class PostmanConfigurationController { + + + + +
+ + + + diff --git a/Postman/Postman-Mail/PostmanMessage.php b/Postman/Postman-Mail/PostmanMessage.php index a85687e..2af67ef 100644 --- a/Postman/Postman-Mail/PostmanMessage.php +++ b/Postman/Postman-Mail/PostmanMessage.php @@ -228,6 +228,13 @@ if ( ! class_exists( 'PostmanMessage' ) ) { $this->logger->debug( sprintf( 'Forced From email address: before=%s after=%s', $this->getFromAddress()->getEmail(), $forcedEmailAddress ) ); $this->getFromAddress()->setEmail( $forcedEmailAddress ); } + + if ( $options->is_fallback ) { + $fallback_email = $options->getFallbackFromEmail(); + $this->logger->debug( sprintf( 'Fallback: Forced From email address: before=%s after=%s', $this->getFromAddress()->getEmail(), $fallback_email ) ); + $this->getFromAddress()->setEmail( $fallback_email ); + } + $forcedEmailName = $options->getMessageSenderName(); if ( $options->isSenderNameOverridePrevented() && $this->getFromAddress()->getName() !== $forcedEmailName ) { $this->logger->debug( sprintf( 'Forced From email name: before=%s after=%s', $this->getFromAddress()->getName(), $forcedEmailName ) ); diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php index d2b01ae..6a4f442 100644 --- a/Postman/PostmanInputSanitizer.php +++ b/Postman/PostmanInputSanitizer.php @@ -85,6 +85,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) { $this->sanitizeInt( 'Fallback port', PostmanOptions::FALLBACK_SMTP_PORT, $input, $new_input ); $this->sanitizeString( 'Fallback security', PostmanOptions::FALLBACK_SMTP_SECURITY, $input, $new_input ); $this->sanitizeString( 'Fallback auth', PostmanOptions::FALLBACK_SMTP_USE_AUTH, $input, $new_input ); + $this->sanitizeString( 'Fallback username', PostmanOptions::FALLBACK_FROM_EMAIL, $input, $new_input ); $this->sanitizeString( 'Fallback username', PostmanOptions::FALLBACK_SMTP_USERNAME, $input, $new_input ); $this->sanitizePassword( 'Fallback password', PostmanOptions::FALLBACK_SMTP_PASSWORD, $input, $new_input, $this->options->getFallbackPassword() ); diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php index 8825681..b6eaaf4 100644 --- a/Postman/PostmanOptions.php +++ b/Postman/PostmanOptions.php @@ -118,6 +118,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) { const FALLBACK_SMTP_HOSTNAME = 'fallback_smtp_hostname'; const FALLBACK_SMTP_PORT = 'fallback_smtp_port'; const FALLBACK_SMTP_SECURITY = 'fallback_smtp_security'; + const FALLBACK_FROM_EMAIL = 'fallback_from_email'; const FALLBACK_SMTP_USE_AUTH = 'fallback_smtp_use_auth'; const FALLBACK_SMTP_USERNAME = 'fallback_smtp_username'; const FALLBACK_SMTP_PASSWORD = 'fallback_smtp_password'; @@ -286,7 +287,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) { public function getEnvelopeSender() { if ( $this->is_fallback ) { - return $this->getFallbackUsername(); + return $this->getFallbackFromEmail(); } if ( isset( $this->options [ PostmanOptions::ENVELOPE_SENDER ] ) ) { @@ -296,12 +297,18 @@ if ( ! class_exists( 'PostmanOptions' ) ) { public function getMessageSenderEmail() { if ( $this->is_fallback ) { - return $this->getFallbackUsername(); + return $this->getFallbackFromEmail(); } if ( isset( $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ] ) ) { return $this->options [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; } } + + public function getFallbackFromEmail() { + if ( isset( $this->options [ PostmanOptions::FALLBACK_FROM_EMAIL ] ) ) { + return $this->options [ PostmanOptions::FALLBACK_FROM_EMAIL ]; } + } + public function getMessageSenderName() { if ( isset( $this->options [ PostmanOptions::MESSAGE_SENDER_NAME ] ) ) { return $this->options [ PostmanOptions::MESSAGE_SENDER_NAME ]; } @@ -534,10 +541,6 @@ if ( ! class_exists( 'PostmanOptions' ) ) { return $this->isPluginSenderEmailEnforced(); } public function isPluginSenderEmailEnforced() { - - if ( $this->is_fallback ) { - return true; - } if ( $this->isNew() ) { return self::DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED; } -- cgit v1.2.3