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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | incorrect-drupalmail-example-2879106-3.patch | 966 bytes | daniel.moberly |
| #2 | incorrect-drupalmail-example-2879106-2.patch | 745 bytes | daniel.moberly |
Comments
Comment #2
daniel.moberly commentedI 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
Comment #3
daniel.moberly commentedJust 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.
Comment #4
dinesh18 commentedI have verified the patch and it works as expected.
Comment #7
sk33lz commented#3 applies cleanly to 8.6.x and works as intended. Moving status to RTBC.
Comment #8
alexpottThis 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::sendMailMessageswe do: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...
Comment #15
quietone commentedThere 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.
Comment #18
kim.pepperClosing as this issue has been at Needs Info for more than 3 months. Please re-open if you feel the problem is still relevant.