Problem/Motivation

This was partly resolved in #209672: Use site name in From: header for system e-mails, but apparently it was not enough for all email clients.

Original issue summary:
The aim of this issue is to give e-mails from the site administrator a "from" title set to the website name and not just an e-mail address.

In Drupal 5 this was possible by configuring "Site Webmaster" <webmaster@site.com> in Site information, but since 6.x the additional validation prevents such an e-mail address configuration.

You are now limited to just the e-mail address, without a name. Hence site e-mails appear to be from just webmaster@site.com, which is just not as nice :)

Proposed resolution

Specify in the "From:" header the site name along with the site email address.

Remaining tasks

  • The patch should not give Notices/Errors on sites which do not have site name defined
  • Get RTBC.

User interface changes

In your email, you'll see the Site name instead of the email address.

Screen capture attached of my email client:
Screen capture of emails before and after

API changes

None.

CommentFileSizeAuthor
#2 3098024-mail-from-2.patch3.88 KBsokru

Comments

sokru created an issue. See original summary.

sokru’s picture

StatusFileSize
new3.88 KB

Rerolled patch from #209672-146: Use site name in From: header for system e-mails, credits to @Andrew Answer and @jcisio

alexpott’s picture

Issue tags: -Usability, -Regression

As per my comment on the other issue. I'm not convinced this is a fix. We need to understand more about the problems @Andrew Answer is experiencing - because with the default Drupal 8 core mailer the from address on the email will come from the headers.

This issue summary is incorrect. It's definitely not about the email client - it is probably about an email module on the Drupal side - and we need to work out which one as I think the bug is there and not in core.

alexpott’s picture

Copying the previous issue summary is incorrect. What we need are steps to reproduce so we can isolate why @Andrew Answer is experiencing the problem.

jcisio’s picture

Checking out a site that we experienced problem, there is mailsystem + swiftmailer. Do you happen to have the same, sokru?

alexpott’s picture

So @Berdir pointed out that #2641772: From header is dropped, incompatiblity with Simplenews exists and has been fixed in the Switfmailer module. Are we sure that we're nmot dealing with old Swiftmailer code here?

sokru’s picture

We're running also mailsystem + swiftmailer. Swiftmailer is on dev 694cbf2 and so it includes #2641772: From header is dropped, incompatiblity with Simplenews.

avpaderno’s picture

Title: Use site name in From: header for system e-mails (Drupal 8) » Use site name in From: header for system e-mails
alexpott’s picture

@sokru well we need to understand why it's not using the header from. ANy chance you can debug that?

sokru’s picture

Status: Needs work » Closed (works as designed)

Turned out to be Mailgun contrib module sender that messes up the From header. We've Swiftmailer as a formatter and Mailgun as a sender. Changing the sender fixes the issue. In Mailgun's testmail hook_mail there's proof that something wrong in their end:
$message['from'] = sprintf('%s <%s>', $site_name, $message['from']);

So I'm closing this as a non-core issue.

Edit: Created an issue to Mailgun #3098127: Use site name in From: header, but other mail senders might have this issue too.

jcisio’s picture

We use the beta2 version of swiftmailer. I can also confirm it is not a Drupal core bug. Thanks @alexpott and @berdir for the information.