Make WordPress Core

Opened 4 years ago

#43425 new defect (bug)

WP_Mail BCC and CC - RCPT TO Errors

Reported by: JWGarber1725 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.4
Component: Mail Keywords:
Focuses: Cc:

Description

Adding BCC and CC Fields are having inconsistent results. Undeliverable emails, incorrect "RCPT TO" Addresses in SMTP Communication etc. "RCPT TO" is being set to "Message-ID".

See Tests Below - I tested with standard PHP Mail and wp_mail
If anyone has any pointers that would be great.

Windows Server 2012R2
IIS: 8.5
PHP: 7.0.9
WP: 4.9.4
No special plugins or code.

Test 1: Standard PHP Mail with CC Field

	$headers = 'From: Test <[email protected]>' . "\r\n" . 'cc: [email protected]';
	$to = "[email protected]";
	$subject = "TEST SUBJECT";
	$body = "Test";

if (mail($to, $subject, $body, $headers)) {
    echo("Message successfully sent");
} else {
    echo("Message sending failed");
}

Results
Both emails received. Content looks ok


Test 2: Standard PHP Mail with BCC Field

	$headers = 'From: Test <[email protected]>' . "\r\n" . 'bcc: [email protected]';
	$to = "[email protected]";
	$subject = "TEST SUBJECT";
	$body = "Test";

if (mail($to, $subject, $body, $headers)) {
    echo("Message successfully sent");
} else {
    echo("Message sending failed");
}

Results: Both emails were received
However. The body of each email now has the letter "b" appended to the content.

Body Content

b

Test

Is something in WP causing this or is this an issue in Windows PHP??


Test 3: WordPress wp_mail with CC Field

	$headers = 'From: Test <[email protected]>' . "\r\n" . 'cc: [email protected]';
	$to = "[email protected]";
	$subject = "TEST SUBJECT";
	$body = "Test";

if (wp_mail($to, $subject, $body, $headers)) {
    echo("Message successfully sent");
} else {
    echo("Message sending failed");
}

Results
CC never received - SMTP Log file shows: [2018.02.26] 16:46:04 [55583] CMD: RCPT TO:<945dc26bed6e74aeec984fc4ae828e32@…>
Why did the CC field get changed? It looks like the "CC" Field is now the "Message-ID" as they are the same now.

Gmail received the copy as expected.


Test 4: WordPress wp_mail with BCC Field

	$headers = 'From: Test <[email protected]>' . "\r\n" . 'bcc: [email protected]';
	$to = "[email protected]";
	$subject = "TEST SUBJECT";
	$body = "Test";

if (wp_mail($to, $subject, $body, $headers)) {
    echo("Message successfully sent");
} else {
    echo("Message sending failed");
}

Results
Same as Test 3 -- The BCC Field "RCPT TO" command became the "Message-ID"??
Gmail received the copy but still had the letter "b" appended into the message body.

Any ideas, pointers etc? Suspecting Bug in WordPress or Windows PHP.

Change History (0)

Note: See TracTickets for help on using tickets.