Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#49661 new feature request

mails, Howdy, wp_mail() and filters spreading

Reported by: arena's profile arena Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4
Component: Mail Keywords: has-patch
Focuses: Cc:

Description

Hello,

The different mails that are build to be sent with function wp_mail() have different ways of doing it. Some are using str_replace(), others are using sprintf(), have a different vocabulary (SITENAME, SITE_NAME, ###SITENAME### ...)

Last but not least, some have different filters : from No filters to subject and/or content and/or mail headers and here again with different vocabularies ( filter_prefix_content or filter_prefix_message) ...

So when you want to change some mails that belong to a group of mails (admin, network, privacy ..), you have to dig in the code and eventually ask for specific changes for this or that mail.

With privacy, and locally for legal purpose, related mails must be sent by a new profile in the organisation, by some sort of a new WP "role" that is still to be created : the cop ... for Chief Of Privacy . In Europe, we call him a dpo.

The following patch proposes to have all mails equals (except some specific ones related to wp updates).

Subject and Mail body are templates.
The {{Mustache}} standard is adopted.
All mails have an id and belong to a group.

This is an encapsulation of wp_mail() with some conventions to get the best results.

With the patch, i attach here

  • a zip file that is a set of .eml files (with some logging in it for debugging purpose)

As a proof of concept, i also attach the three plugins i developped

  • logphpmailer.php : to save eml files
  • wp_mailer_filter.php : sample plugin filtering mail using the new filters of wp_mailer class (here for privacy mails)
  • wp_mailer_logger.php : appends some logging to mail content using the new filters of wp_mailer class

the patch also fixes a bug i detected on the Reply-To mail header (double quotes doubled, added by wp AND phpmailer)

I know this is a big one. Due to CoVid, i am stuck at home in front of my keyboard.

Regards

Attachments (6)

#wp_mailer.patch (143.8 KB) - added by arena 4 years ago.
the patch
wp_mailer_mails.zip (24.8 KB) - added by arena 4 years ago.
the mails tested with some logging
logphpmailer.php (796 bytes) - added by arena 4 years ago.
logphpmailer.php
wp_mailer_filter.php (1.2 KB) - added by arena 4 years ago.
wp_mailer_filter
wp_mailer_logger.php (3.5 KB) - added by arena 4 years ago.
wp_mailer_logger
#wp_mailer-v2.patch (143.8 KB) - added by arena 4 years ago.
v2 of patch

Download all attachments as: .zip

Change History (8)

@arena
4 years ago

the patch

@arena
4 years ago

the mails tested with some logging

@arena
4 years ago

logphpmailer.php

@arena
4 years ago

wp_mailer_filter

@arena
4 years ago

wp_mailer_logger

#1 @arena
4 years ago

Related #46424 1)

#2 @arena
4 years ago

v2 of patch to fix text missing

--- wp-includes/user.php

< +As {{USERNAME}}, this notice confirms that your email address on {{SITENAME}} to {{NEW_EMAIL}}.
---

+As {{USERNAME}}, this notice confirms that your email address was changed on {{SITENAME}} to {{NEW_EMAIL}}.

@arena
4 years ago

v2 of patch

Note: See TracTickets for help on using tickets.