Reputation: 145
This might be a dumb question but if I leave $to = ''
in mail($to,...)
and put $to
to mail headers 'to' => '<[email protected]>'
, might this cause this effect(two 'to' headers)?:
To:
Subject: 123
From: <>
To: <[email protected]>
Upvotes: 2
Views: 254
Reputation: 88657
Never really bothered to look at exactly how mail() behaves until now, just cracked out Wireshark and tried a couple of things and here is the result:
Message sends; To: header appears before From:
mail('[email protected]','Subject','Body',"From: [email protected]");
Message sends; To: header appears after From:
mail('[email protected]','Subject','Body',"From: [email protected]\r\nTo: [email protected]");
Message wont send; PHP tries to do it but doesn't send an RCPT command, just skips straight to DATA which is a protocol violation so the server tells PHP to go away.
mail('','Subject','Body',"From: [email protected]\r\nTo: [email protected]");
Message sends; both To: headers appear in the order they were specified in $additional_headers, after From:
mail('[email protected]','Subject','Body',"From: [email protected]\r\nTo: [email protected]\r\nTo: [email protected]");
Message sends; To: header appears after From: and has the value specified in $additional_headers
mail('[email protected]','Subject','Body',"From: [email protected]\r\nTo: [email protected]");
So it appears that the To: header(s) specified in $additional_headers will override the one auto-generated by PHP from the value of $to, but you will never get multiple To: headers unless you explicitly set them in $additional_headers.
Tested on PHP 5.2.17/win32
Upvotes: 2
Reputation: 6127
You can have multiple to
addresses, if that's what you mean:
mail('[email protected];[email protected]',...);
Upvotes: 0