SMTPMailSystem::mail throws exception "Invalid address: (to)" instead of returning FALSE

Created on 21 July 2021, about 3 years ago
Updated 1 August 2024, about 1 month ago

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

  1. Patch - Done!
  2. Review
  3. 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.
πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Pipeline finished with Success
    2 months ago
    Total: 147s
    #212514
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    27 pass
  • Pipeline finished with Success
    2 months ago
    Total: 142s
    #212518
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Moved 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.

  • Status changed to Needs work about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States japerry KVUO

    Made comments on the MR -- there are BC issues and I think we can use reflection instead of needing another public method.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 161s
    #241016
  • Pipeline finished with Success
    about 1 month ago
    Total: 163s
    #241034
  • Status changed to Needs review about 1 month ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Thanks for the review Jakob - I believe I have implemented all the changes requested.

  • Pipeline finished with Success
    about 1 month ago
    Total: 192s
    #241047
Production build 0.71.5 2024