Mail Bug: Incorrect From Specified

Justin
Forums
Hello. This might not be the right place to report/inquire about something like this, if that's the case let me know please. There's what I'm assuming is a typo here: https://git.drupalcode.org/project/opigno_learning_path/-/blob/8.x-1.x/… $message['from'] = \Drupal::config('system.site')->get('name'); This is passing the site's name rather than the email address as the "from" field for the email. To fix just requires replacing 'name' with 'mail' instead. $message['from'] = \Drupal::config('system.site')->get('mail'); This caused us all sorts of issues today trying to have emails not going out as "on behalf of". Not being super familiar with PHP's mail() and sendmail/postfix, and my attempts to fix through postfix configuration failing, I ended up switching to an SMTP module, first drupal/smtp and then drupal/phpmailer_smtp. However this only exacerbated the situation with total failure to send anything as it was erroring out. The array being sent to Drupal's MailManager::mail was this: array ( 'id' => 'opigno_learning_path_opigno_learning_path_user_subscribe', 'module' => 'opigno_learning_path', 'key' => 'opigno_learning_path_user_subscribe', 'to' => '[email protected]', 'from' => 'SITE NAME', 'reply-to' => NULL, 'langcode' => 'en', 'send' => true, 'headers' => array ( 'X-Mailer' => 'Drupal', 'Sender' => 'SITE NAME', ), ) This caused it to error out as Headers>Sender (nor From afaik) isn't valid when specified in name only, without an email address.
axel

Hi Justin,

Hi Justin,

Thanks for raising this point.

It will be fixed in the next release.