PHP Mail

I see from the PHP manual that the headers for the mail are just a string with a CRLF between each header element::

$headers = "From: webmaster@example.com" . "\r\n" ."CC: somebodyelse@example.com";

But I've been using some code I copied from somewhere that makes the headers an array, and I'm just wondering why or how that works:


$from = "sender<steve@mycompany.com>";
$host = "localhost";
$username = "steve@muycompany.com";
$password = "early237";
$headers = array ('From' => $from,
        'To' => $To,
        'Subject' => $Subject);
$smtp = Mail::factory('smtp',
        array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));
      
$mail = $smtp->send($To, $headers, $Body);


Thanks for any enlightenment.
stevaAsked:
Who is Participating?
 
Eddie ShipmanAll-around developerCommented:
PHP's mail function and the Mail class that you see being used are not the same.
0
 
stevaAuthor Commented:
Ah!  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.