API page: https://api.drupal.org/comment/reply/12067231

The API page has a list of example 'to' addresses, including user@example.com, anotheruser@example.com.

However, the use of a comma followed by a space results in only the first address receiving mail - all other addresses are silently ignored.

A code sample always explains things better!.
The first example results in an email being sent to 'addr1@domain.co.uk' only. The second results in emails being sent to both 'addr1@domain.co.uk' and 'addr2@domain.co.uk'.

drupal_mail( 'foo' , 'bar' , 'addr1@domain.co.uk, addr2@domain.co.uk' , language_default() , array( 'body' => 'test body' , 'subject' => 'test subject' ) , 'addr3@domain.co.uk' );

drupal_mail( 'foo' , 'bar' , 'addr1@domain.co.uk,addr2@domain.co.uk' , language_default() , array( 'body' => 'test body' , 'subject' => 'test subject' ) , 'addr3@domain.co.uk' );

Hopefully I'm submitting this in the right place. I suppose this could be considered to be a bug in core rather than the documentation, not sure.

Comments

jad created an issue. See original summary.

daniel.moberly’s picture

Status: Active » Needs review
StatusFileSize
new745 bytes

I have tested this and confirmed - the example only results in email being sent to the first user. The corrected example (with whitespace removed) results in emails to both users.

Additionally, this is confirmed by documentation - the PHP validation filter used for the email address does not support whitespace. See http://php.net/manual/en/filter.filters.validate.php

Attaching a patch

daniel.moberly’s picture

Version: 7.52 » 8.4.x-dev
StatusFileSize
new966 bytes

Just confirmed this issue also exists in D8. Moving issue to the D8 queue there according to the backport policy. Will open child issue for D7 backport.

Attaching D8 patch.

dinesh18’s picture

I have verified the patch and it works as expected.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sk33lz’s picture

Status: Needs review » Reviewed & tested by the community

#3 applies cleanly to 8.6.x and works as intended. Moving status to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

This documentation is lifted from http://php.net/manual/en/function.mail.php. If it is incorrect we might need to do a lot more, for example in \Drupal\contact\MailHandler::sendMailMessages we do:

$to = implode(', ', $contact_form->getRecipients());

I think we need more information here. For example, was core's PhpMail being used to send the mail, which OS, what's the sendmail config in php.ini etc...

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue tags: +Bug Smash Initiative

There has been no activity here for 3 years and 3 months.

Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kim.pepper’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Closing as this issue has been at Needs Info for more than 3 months. Please re-open if you feel the problem is still relevant.