Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#44501 closed enhancement (fixed)

Change "From" email address for GDPR request confirmation email

Reported by: zaffarn's profile zaffarn Owned by: xkon's profile xkon
Milestone: 5.4 Priority: normal
Severity: normal Version: 4.9.6
Component: Privacy Keywords: has-patch has-unit-tests needs-docs commit has-dev-note
Focuses: Cc:



Is there a way to change the "From" email address for GDPR personal data export request confirmation email, currently when a request is generated through tools -> Export Personal Data, it sends a request confirmation email however the from email is "Wordpress@…" is it possible to change to something like "info@…"


Attachments (4)

44501.diff (6.6 KB) - added by xkon 4 years ago.
44501.2.diff (12.6 KB) - added by xkon 4 years ago.
44501.3.diff (12.5 KB) - added by xkon 4 years ago.
minor edit - correcting the descriptions of unit tests
44501.4.diff (12.2 KB) - added by garrett-eclipse 4 years ago.
Minor refresh to correct some docblocks

Download all attachments as: .zip

Change History (16)

#1 @desrosj
6 years ago

  • Keywords reporter-feedback added
  • Type changed from defect (bug) to enhancement

@zaffarn thanks for the ticket, and welcome to Trac!

The from email for privacy related emails is the default email used by wp_mail(). You can filter this email and name using wp_mail_from and wp_mail_from_name respectively.

Can you tell me more about your use case? If you need all other site emails to come from the default address and all privacy emails to come from another, that may be a good instance to look into adding a filter of some sort.

#2 @zaffarn
6 years ago


Thanks for the swift response, we currently have set "Email address" of wordpress in "Setting - General" as "Info@…" however this works for all other plugins but not this one, this functionality seems to send emails from "Wordpress@…".

With regards to your question are there any uses cases where we may need to use a separate email address, the short answer is yes, normally most automated emails sent by WP can be sent using the generic default email address, however for GDPR request (we) would like to use a different one specifically created for all GDPR requests such as "DPO@…" or "gdpr@…" so that we can keep track of all replies etc easily.

best wishes

This ticket was mentioned in Slack in #core-privacy by desrosj. View the logs.

6 years ago

#4 @garrett-eclipse
5 years ago

  • Keywords needs-patch added; reporter-feedback removed
  • Milestone changed from Awaiting Review to Future Release
  • Owner set to garrett-eclipse
  • Status changed from new to accepted

Hi @zaffarn thank you for the feedback. I definitely see the validity of having the from_email filterable for Privacy requests.

I'm sorry this ticket was raised in our team chat and I missed updating it afterwards.

It was agreed to look into a filter for the reply-to and from email addresses as we felt filtering them specifically would be very helpful for organizations with a DPO as you mentioned.

After reviewing some core implementations it appears the best way to accomplish this would be to introduce the email header as filterable and pass it along to wp_mail. As currently using thewp_mail_from and wp_mail_from_name filters would affect all email since those filters are unaware it's for a privacy request.

Two coding examples of this;
Pass Change Email -
Email Change Email -

I'll look into this further when I have time.

Last edited 5 years ago by garrett-eclipse (previous) (diff)

#5 @xkon
4 years ago

  • Milestone changed from Future Release to 5.4
  • Owner changed from garrett-eclipse to xkon
  • Status changed from accepted to assigned

I'll see if I can get a patch on this tomorrow, this will be nice for 5.4 and doesn't seem complicated :).

4 years ago

#6 @xkon
4 years ago

  • Keywords has-patch needs-testing needs-dev-note needs-unit-tests added; needs-patch removed

44501.diff introduces 4 new hooks to allow the filtering of all the privacy-related e-mails.

It will now be possible to change the From addresses on these emails as it's common to have a different address for DPO purposes.

All filters contain equal data and an easy way to test would be:


function my_privacy_mail_headers( $headers, $subject, $content, $request_id, $email_data ) {

	$headers = array(
		'From: My Name <>',

	return $headers;
add_filter( 'user_request_action_email_headers', 'my_privacy_mail_headers', 10, 5 );
add_filter( 'user_request_confirmed_email_headers', 'my_privacy_mail_headers', 10, 5 );
add_filter( 'user_erasure_complete_email_headers', 'my_privacy_mail_headers', 10, 5 );
add_filter( 'wp_privacy_personal_data_email_headers', 'my_privacy_mail_headers', 10, 5 );

I'll be looking into adding unit tests also asap.

4 years ago

#7 @xkon
4 years ago

  • Keywords has-unit-tests needs-docs added; needs-unit-tests removed

44501.2.diff also adds the necessary unit tests.

4 years ago

minor edit - correcting the descriptions of unit tests

#8 @xkon
4 years ago

@garrett-eclipse can you take a look here for a quick 2nd test? Patch still applies fine along with unit tests.

According to my tests, I'm ok for marking this for commit as it's easier to change the headers this way per-email but it would be good to get a 2nd look. Feel free to mark it if all good :-).

4 years ago

Minor refresh to correct some docblocks

#9 @garrett-eclipse
4 years ago

  • Keywords commit added; needs-testing removed

Thanks @xkon this worked really nicely, some very minor tweaks in 44501.4.diff

  1. In the user_request_confirmed_email_headers docblock corrected the mention of $email_text as it's $content that's used. And updated the $email_data block to match the expected for that email.
  2. Updated the description for user_erasure_complete_email_headers, and the $email_data contents to match the email.
  3. Updated user_request_action_email_headers to swap $email_text for $content.

Unit tests worked nicely and all my tests cleared (I appreciate the testing code made things simple)

Marking for final review.

This ticket was mentioned in Slack in #core by francina. View the logs.

4 years ago

#11 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 47279:

Privacy: Introduce filters for the headers of all the privacy-related e-mails:

  • wp_privacy_personal_data_email_headers
  • user_request_confirmed_email_headers
  • user_erasure_complete_email_headers
  • user_request_action_email_headers

Props xkon, garrett-eclipse, zaffarn, desrosj.
Fixes #44501.

#12 @garrett-eclipse
4 years ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.