Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to override the fallback email #5342

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/test-vip-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ public function test__mail_from() {
$this->assertStringContainsString( 'From: WordPress <donotreply@wpvip.com>', $header );
}

public function test__custom_mail_from() {
Constant_Mocker::define( 'VIP_FROM_EMAIL_FALLBACK', 'donotreply@wpvip-email.com' );
$GLOBALS['all_smtp_servers'] = [ 'server1', 'server2' ];

wp_mail( 'test@example.com', 'Test', 'Test' );
$mailer = tests_retrieve_phpmailer_instance();
$header = $mailer->get_sent()->header;

$this->assertStringContainsString( 'From: WordPress <donotreply@wpvip-email.com>', $header );
}

public function test__has_tracking_header_with_key() {
$GLOBALS['all_smtp_servers'] = [ 'server1', 'server2' ];

Expand Down
4 changes: 4 additions & 0 deletions vip-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public function phpmailer_init( &$phpmailer ): void {
}

public function filter_wp_mail_from() {
if ( defined( 'VIP_FROM_EMAIL_FALLBACK' ) ) {
return constant( 'VIP_FROM_EMAIL_FALLBACK' );
}

return 'donotreply@wpvip.com';
}

Expand Down