Using the mail function in php
Posted on 2006-06-16
It's incredible that it's so difficult to find out how to do something SO OBVIOUS.
I want to send a programatically generated email using the php mail function.
I want to specify BOTH a cc AND a from email address.
I finally figured out how to do one or the other, but not both.
Here's the code:
$mailto = "firstname.lastname@example.org";
$subj = "On-Line Invoice Payment";
$body = "Some text";
$header = "From: payments@LSS.com \r\n Cc: email@example.com";
$mres = mail($email, $subj, $body, $header);
The mail gets sent. Using the specific configuration above, there is NO from or cc.
If I specify EITHER JUST the From or the Cc in the $header variable, it works fine.
I've spent literally HOURS with Google, the php web site, etc., trying to figure this out.
(1) What's the trick?
(2) Why do they make it so INCREDIBLY difficult to do something SO SIMPLE?