I know that the code to send an email to multiple addresses is:

$to = "ADDRESS1, ADDRESS2 \r\n";
$headers .= "CC: ADDRESS3 \r\n";
$headers .= "BCC: ADDRESS4 \r\n";

And I know that you can add a reply-to address with:

$headers .= "Reply-To: ADDRESS5, ADDRESS6 \r\n";

My question is...what code to use for the reply-to fields so that you can add a CC and BCC. I've tried:

$headers .= "Reply-To: ADDRESS5 \r\n";
$headers .= "Reply-CC: ADDRESS6\r\n";
$headers .= "Reply-BCC: ADDRESS7\r\n";

And I've tried:

$headers .= "Reply-To: ADDRESS5 \r\n";
$headers .= "CC: ADDRESS6\r\n";
$headers .= "BCC: ADDRESS7\r\n";

Nothing's worked so far. Any thoughts?

Eric

Recommended Answers

The clue here may be "Nothing's worked". Did you at least test that your email server/service is working with those (email) command by telnet?
https://www.google.com/search?q=Sending+or+viewing+emails+using+telnet&gl=US for example.

I've lost track of folk that …

Jump to Post

All 4 Replies

rproffitt,

Thanks for the response. Apologies for not clarifying the first two statements. Let me try this again.

I have an HTML form that, when the Submit button is clicked, an email is sent using PHP. The code below successfully sends an email to multiple addresses...two addresses in the TO field, one address in the CC field and one address in the BCC field:

$to = "ADDRESS1, ADDRESS2 \r\n";
$headers .= "CC: ADDRESS3 \r\n";
$headers .= "BCC: ADDRESS4 \r\n";

When the email is received, the code below successfully adds one or more addresses in the TO field automatically:

$headers .= "Reply-To: ADDRESS5, ADDRESS6 \r\n";

I know the codes above work because I've tested them multiple times. The problem is that I want to not only automatically put addresses in the TO field, I want to put addresses in the CC & BCC fields. I've tried...

$headers .= "Reply-To: ADDRESS5 \r\n";
$headers .= "Reply-CC: ADDRESS6\r\n";
$headers .= "Reply-BCC: ADDRESS7\r\n";

...and I've tried...

$headers .= "Reply-To: ADDRESS5 \r\n";
$headers .= "CC: ADDRESS6\r\n";
$headers .= "BCC: ADDRESS7\r\n";

...but neither option works. Is is possible to automatically add addresses to the CC and/or BCC fields automatically using the Reply-To command in PHP?

Eric

commented: Before you test with PHP you test by manually sending that email. Some folk won't do this. +15

See Notes at https://www.php.net/manual/en/function.mail.php in regard to LF CR handling. I can not guess if you have that issue. You must test your messages manually at times to see if your email server accepts what headers you are creating.

@egoche - I've corrected your code formatting twice. I won't do it again. Please use the code block tool </> to insert code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.