Problem/Motivation
According to MailInterface::mail() :
Returns TRUE if the mail was successfully accepted for delivery, otherwise FALSE.
SMTPMailSystem::mail() breaks the contract and @throws \PHPMailer\PHPMailer\Exception instead.
Steps to reproduce
- Create a user without setting email and blocked
- Try to unblock the user
Proposed resolution
Follow the MailInterface::mail() contract and return FALSE when message could not be delivered for whatever reason.
Remaining tasks
- Patch - Done!
- Review
- Commit
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
TBD
Original report
This issue is very similar to #3174535: Invalid address: (cc): PHPMailer Issue. But that issue comes if we login with a different user role. It's working fine when we are with the administrator role and when we turn off the smtp mail system everything will work as expected.
The website encountered an unexpected error. Please try again later.
Drupal\Core\Entity\EntityStorageException: Invalid address: (to): in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).Steps to reproduce
- Enable and configure of the SMTP module.
- Attempt to send a email on via workflow on state transition.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | smtp-3224734-10-12-interdiff.txt | 2.44 KB | rosk0 |
| #12 | smtp-3224734-12.patch | 8.22 KB | rosk0 |
| #9 | smtp-3224734-8-9-interdiff.txt | 694 bytes | rosk0 |
| #9 | smtp-3224734-9.patch | 6.14 KB | rosk0 |
Issue fork smtp-3224734
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
navodit commentedComment #3
Adamation commentedHi
I get the same issue when using content_moderation_notifications to send the email on a workflow transition.
It'll only send email to the site email address, and attempt to send to additional emails address we get this same error.
and
I think the TO/REPLY-TO format that content_moderation_notifications sends to the SMTP module is the cause, but not sure on a fix.
Comment #4
tr commentedComment #5
rjhammond commented@Adamation - relating to the "Invalid address" issue when using content_moderation_notification, this patch solved our situation.
The problem occurs when selecting to disable the site email address notification. Hope it helps your case.
Comment #6
rosk0We also experienced this exception , however when user account was blocked/unblocked , notification for those operations enabled but the account didn't had email set.
According to MailInterface::mail() :
SMTPMailSystem::mail()breaks the contract and@throws \PHPMailer\PHPMailer\Exceptioninstead.Attached patch wraps most of the
SMTPMailSystem::mail()body into a separate function to catch PHPMailer exceptions. I tried to minimise the change to simplify review.Comment #8
rosk0In this patch:
list()=>[]Comment #9
rosk0Found an issue in the patch - wrong parameter of the
$messageused in exception logger.Comment #10
rosk0Re-roll for the latest dev - patch stopped applying after version 1.1.
Comment #12
rosk0Fixed tests.
FWIW interdiff between 9 and 10 is not representative - visual patch file comparison gives way better picture than what is generated by interdiff.
Comment #15
ericgsmith commentedMoved patch from #12 to MR.
While patch applies cleanly to 8.x-1.3 and all tests on the MR passed, manually testing found a error as 8.x-1.3 introduced additional code that expected logger to be a factory instead of the logger object.
Rather than update the code in debug method I have reverted the change to the constructor logic. I think it could be considered outside the scope of this issue and in recent times keeping the factory as the dependency is preferred.
Comment #16
japerryMade comments on the MR -- there are BC issues and I think we can use reflection instead of needing another public method.
Comment #17
ericgsmith commentedThanks for the review Jakob - I believe I have implemented all the changes requested.
Comment #18
dtfabio commentedHi ericgsmith,
Thanks for the work, merge request 37 solved the problem for me.
Site Drupal core version 10.2.8, PHP version 8.1.
Greetings,
Fabio