WordPress / wordcamp.org

WordCamps are casual, locally-organized conferences covering everything related to WordPress.
https://wordcamp.org
130 stars 74 forks source link

Mail: Set the default sender in email from a WordCamp site to the name of the WordCamp #510

Open coreymckrill opened 4 years ago

coreymckrill commented 4 years ago

Based on this conversation.

There are a lot of different places in the WordCamp codebase where we send email to someone using wp_mail. These emails are often notifications or reminders. The default sender is usually WordPress <wordpress@year.city.wordcamp.org>, though in some of these places, we are already manually setting the sender to something else, generally the WordCamp name. However, each place we do this, it's implemented slightly differently.

wp_mail has two filters related to the sender: wp_mail_from_name filters the name, and wp_mail_from filters the email address. (Reply-To doesn't have a filter, and must be set as a header during the wp_mail call.)

It seems like we would always want the sender name to be the name of the WordCamp, rather than WordPress. We could accomplish this by hooking to the wp_mail_from_name in an mu-plugin, and then removing the other custom implementations elsewhere in our codebase. Of course, we'd want to use a conditional so that if there was an exception, our filter wouldn't override it.

It might also make sense to change the default sender email address to city@wordcamp.org, though I'm less certain about this.

iandunn commented 4 years ago

I like the idea 👍

always want the sender name to be the name of the WordCamp

I think so, except for edge cases like Central, Plan, etc. get_wordcamp_name() might already gracefully handle those, but get_bloginfo( 'name' ) might be a bit safer 🤷‍♂️

change the default sender email address to city@wordcamp.org

That'd be good, but we'd have to be careful to not trigger anti-spam filters. It might be safer to leave From in tact, and set Reply-To to the city@ instead (via phpmailer_init && addCustomHeader() maybe).

Related:

https://github.com/WordPress/wordcamp.org/blob/production/public_html/wp-content/plugins/wordcamp-organizer-reminders/wcor-mailer.php#L95-L148

Maybe this would fallback to get_option( 'admin_email' ) on non-event sites like Central?