[wp-trac] [WordPress Trac] #60420: Default sender address

WordPress Trac noreply at wordpress.org
Sun Jul 13 16:04:28 UTC 2025


#60420: Default sender address
-----------------------------+------------------------------
 Reporter:  thinlinecz       |       Owner:  (none)
     Type:  feature request  |      Status:  closed
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Mail             |     Version:  1.5.1.2
 Severity:  normal           |  Resolution:  wontfix
 Keywords:                   |     Focuses:
-----------------------------+------------------------------
Changes (by SirLouen):

 * status:  new => closed
 * type:  defect (bug) => feature request
 * version:   => 1.5.1.2
 * resolution:   => wontfix


Comment:

 This was forced in [3214], mainly because of #1532, 20 years ago, and has
 prevailed until now.

 They switched from
 {{{
 "From: " . get_settings('admin_email') . "\n"
 }}}

 To

 {{{
 "From: wordpress@" . preg_replace('#^www\.#', '',
 strtolower($_SERVER['SERVER_NAME'])) . "\n" .
 }}}

 Which did not make any sense to me at first in the early days. In fact, my
 first impression has always been that the `From:` should logically be the
 `admin_email` (just because it could be manually edited)

 But the reality is that admin email could be significantly different from
 the domain (you could be using a Gmail admin email, and your domain could
 be whatever.example.com). So the better option here (unless you used some
 SMTP relay with a different domain than the one in your website), was
 setting something at whatever.example.com

 But what `something` was the best in this case?

 Arguably we could set one of the classic sets, like `webmaster`, `info`,
 etc… but then anyone could come like you saying why `webmaster` instead of
 `info` since `info` is more popular in a never-ending discussion.

 Another option could be, adding in the front-end the option to set this in
 another field. But there is a WP theory, that WP should work somewhat like
 a framework, with the minimum fields possible in the backend. If one field
 is not 99.99% essential, it should go away. And instead of adding a
 million fields that customize everything to the minimum detail, WordPress
 uses a "hidden field" strategy with the concept of "filter hooks". This
 way, you could perfectly customize this, but unfortunately without a
 visual tip in the front end (because as I say, not everything could be in
 the front end, only in the [https://developer.wordpress.org developer
 docs]).

 And here is where the hook
 [https://developer.wordpress.org/reference/hooks/wp_mail_from/
 wp_mail_from] comes handy. You can edit this hook, in order, not only to
 set your from easily like this:

 {{{
 add_filter( 'wp_mail_from', function custom_wp_mail_from(
 $original_email_address ) {
 return 'something at whatever.example.com';
 }
 }}}

 But also, you could do some logical stunts to use a different `From:`
 based on certain conditions (for example, if you would like to send
 privacy emails with a `privacy at example.com`, you could).

 Furthermore, there are some plugins that provide you with the field in the
 front-end, just in case you would rather not touch the code.

 If you are planning to go full DYI, WP needs a little extra tweaking
 beyond the UI, but pretty much like any other framework out there. The
 important thing here is that you can actually do something to remediate
 the problem.

 This said, I'm closing this as `wontfix` as this is the expected default
 behaviour.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60420#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list