Problem/Motivation
When a user doesn't enter anything in CC and BCC fields in the Test email form, then it throws the below error:
Drupal\Core\Entity\EntityStorageException: Invalid address: (cc): in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of /var/www/d8/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
PHPMailer\PHPMailer\Exception: Invalid address: (cc): in PHPMailer\PHPMailer\PHPMailer->addOrEnqueueAnAddress() (line 1081 of /var/www/d8/vendor/phpmailer/phpmailer/src/PHPMailer.php).Steps to reproduce
- Enable the Reroute EMail module.
- Navigate to the Test Email Form.
- Enter the To email address as it's mandatory field and keep the cc & bcc fields as is.
- Submit the form and you will get The website encountered an unexpected error. issue.
The reason it sends empty CC and BCC values but SMTP/PHPMailer modules expect headers which has both key & value.
Array
(
[cc] =>
[bcc] =>
[subject] => Reroute Email Test
[body] => Reroute Email Body
)Proposed resolution
Need to unset the keys which have empty values. For example: in the above case, CC & BCC should not be part of the params array, if empty.
| Comment | File | Size | Author |
|---|
Issue fork reroute_email-3174784
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pushpinderchauhan commentedComment #5
pushpinderchauhan commentedComment #7
larowlanReviewed the patch, and can confirm this resolves the issue.
It adds tests coverage too
Great work @er.pushpinderrana
Comment #8
kleiton_rodrigues commentedThe patch #5 has been applied cleanly
good for me
RTBC+1
Comment #14
bohart@er.pushpinderrana, @kleiton_rodrigues, @larowlan, thanks for your contribution!
All the changes are committed to both 8.x-1.x-dev and 2.x-dev branches now.
So the fix will be included in the next module versions.
In the meantime, a few additional test coverage changes have been added also (to test cc/bcc values/headers for all tests).
Marking this issue as fixed now, thanks!