diff --git a/api/src/Mail.php b/api/src/Mail.php index 52ba7f4b40..b0ce372711 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -7171,4 +7171,21 @@ class Mail error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); } + + /** + * This function gets array of email addresses in RFC822 format + * and tries to normalize the addresses into only email addresses. + * + * @param array $_addresses Addresses + */ + static function stripRFC822Addresses ($_addresses) + { + $matches = array(); + foreach ($_addresses as &$address) + { + preg_match("/<([^\'\" <>]+)>$/", $address, $matches); + if ($matches[1]) $address = $matches[1]; + } + return $_addresses; + } } diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index b666ec9607..a4328a0834 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2964,7 +2964,7 @@ class mail_compose $smime_success = $this->_encrypt( $mail, $_formData['smime_encrypt'] == 'on'? Mail\Smime::TYPE_SIGN_ENCRYPT: Mail\Smime::TYPE_SIGN, - $_formData['to'], + Mail::stripRFC822Addresses($_formData['to']), $identity['ident_email'], $_formData['smime_passphrase'] ); @@ -2980,7 +2980,7 @@ class mail_compose $smime_success = $this->_encrypt( $mail, Mail\Smime::TYPE_ENCRYPT, - $_formData['to'], + Mail::stripRFC822Addresses($_formData['to']), $identity['ident_email'] ); }