Problem/Motivation
When sending a test email using /admin/config/system/mailer/test, the process may throw PHP errors due to missing or empty parameters passed to the Symfony Mailer integration.
Example in logs:
TypeError: stristr(): Argument #1 ($haystack) must be of type string, array given in core/modules/editor/src/Plugin/Filter/EditorFileReference.php:83
The problem occurs because some message parameters—particularly body, to, from, and subject—can be empty or even empty arrays when the mail is generated via the Mailer test form.
Steps to reproduce
- Enable the Symfony Mailer module.
- Go to
/admin/config/system/mailer/test. - Leave one or more fields empty (e.g. Body, Subject, From).
- Click “Send test mail”.
- Get errors like:
TypeError: stristr(): Argument #1 ($haystack) must be of type string, array given
or
TypeError: Drupal\symfony_mailer\Address::__construct(): Argument #1 ($email) must be of type string, null given
Proposed resolution
Add proper checks before using message parameters when building or sending test mails. Specifically:
Issue fork mail_entity_queue-3554506
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 #3
evamtinezFixed in #3555795
Comment #4
facine commented