Problem/Motivation
This is the Drupal 7 backport of #209672: Use site name in From: header for system e-mails.
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
User interface changes
In your email, you'll see the Site name instead of the email address.
Screen capture attached of my email client:
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#32 | 3098058-32.patch | 8.43 KB | mcdruid |
#32 | interdiff-3098058-31-32.txt | 1.16 KB | mcdruid |
#25 | after.png | 2 KB | alexandra.vecher |
#25 | before.png | 1.24 KB | alexandra.vecher |
#23 | interdiff_18_23.txt | 2.55 KB | SAVEL |
Comments
Comment #12
alexpottHere's the patch from @naxoc. Crediting all the contributors from that issue because I think they all worked on the D7 patch too.
Comment #13
apadernoComment #14
sjerdoIf we're considering backporting this to D7, we should also directly backport #2936032: Sites named with special characters cannot send mail. Otherwise we'll be introducing possible bugs for some websites (which we don't want since D7 should be stable).
We should check whether similar bugs of this patch were reported and backport the fixes.
Comment #15
sjerdoComment #16
alexpott@sjerdo great catch. I think we should combine the issues for D7.
Comment #17
SAVEL CreditAttribution: SAVEL as a volunteer and at EPAM Systems commentedI'm working on backporting #2936032: Sites named with special characters cannot send mail.
Comment #18
SAVEL CreditAttribution: SAVEL as a volunteer and at EPAM Systems commentedI've backported #2936032: Sites named with special characters cannot send mail.
Please, review.
Comment #19
nikolas.tatianenko CreditAttribution: nikolas.tatianenko at EPAM Systems commentedReviewed.
"Sites named with special characters cannot send mail" - solved
Observation:
I assume that email should be replaced by site name.
Is the current behaviour expected?
Comment #20
SAVEL CreditAttribution: SAVEL as a volunteer and at EPAM Systems commentedNikolas, it seems like it's Gmail's special behavior with long (or weird) from texts.
I've tried to change a site's name to a shorter one: 'diymus, LTd (x-fac)' and now it's showing at GMAIL UI.
I've also tried to send an email to yopmail with a longer name "Mycompanyname ()<>[]:;@\\,.\"" and it was ok.
Screenshots are attached.
Comment #21
nikolas.tatianenko CreditAttribution: nikolas.tatianenko at EPAM Systems commentedOk.
Let's summarize:
* Site name used instead of email: Done
* Site name encapsulate special characters: Done
Great work!
Comment #22
mcdruidThanks for working on this.
How do we address the concerns expressed by @David_Rothstein / @xjm in the parent issue, but specifically about introducing this to D7 now:
This might be an unexpected change for some sites that'd break things like e-mail filters / forwarding set-ups that might have been in place for years.
Comment #23
SAVEL CreditAttribution: SAVEL as a volunteer and at EPAM Systems commentedNice catch, @mcdruid!
I've modified the patch so that default behavior isn't changed.
Now to enable showing a site name in "From" header one needs to set 'site_mail_display_sitename' variable to true.
For example, by executing:
or changing settings.php
I've also added tests that cover both cases.
Please, review
Comment #24
apadernoThe patch does what expected, and it adds tests. To me, this is RTBC.
Comment #25
alexandra.vecher CreditAttribution: alexandra.vecher at EPAM Systems commentedTested. The results in attached files
Comment #27
mcdruidLooks like this was an unrelated testbot snafu; a retest came back green.
I'd like to get this in (we could just about squeeze it into the next release due 2012-12-02 so in one week).
However, I have one or two fairly small tweaks I'd like to suggest:
1) The new
drupal_format_mail_name()
function is a fairly straight backport of formatDisplayName(). Let's also make the function name match more closely (e.g.drupal_mail_format_display_name()
even though that's getting fairly long).2) Thank you for adding the variable in #23 - however, let's add an entry to
default.settings.php
for this which explains what it does, and sets it to TRUE for new sites (although we could ask whether those are actually "a thing" for D7 ;).I think maybe the variable should be called
mail_display_name_site_name
although I'm not sure there's a "right answer" for that.It would also be good to add a Change Record / Notice for this pointing out that existing sites might want to enable this feature by setting the variable e.g. in
settings.php
Leaving at "Needs work" for those changes.
I'll also add this to #3179845: [meta] Priorities for 2020-12-02 bugfix release of Drupal 7.76 / 7.77 though as I think we can get it into the next release if we work quickly.
Comment #28
mcdruidImplemented suggestions from #27
Comment #29
mcdruidOops. This time without the typo.
Comment #31
mcdruidMy mistake; didn't rename the variable in the new tests.
Comment #32
mcdruidOh, interesting - I hadn't spotted the short array syntax in the calls to
str_replace()
.I've also fixed a typo in a comment a few lines below those - out of scope but annoying and not really worth a new issue.
Comment #33
mcdruidBack to RTBC
Comment #34
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedRTBM, +1 from me for merge
I like that it is opt-in and that new sites opt-in automatically.
Should add some release notes and a CR so people know that they can easily enable it now.
Comment #36
mcdruidThank you everybody!