[thelist] php mail cc

Nick Daverin ndaverin at marian.org
Fri Feb 23 10:10:07 CST 2007


Joel D Canfield wrote:
> any tips on why this doesn't actually send the CC?
>
> <?php
> if(isset($_POST['submit'])) {
> 	$to = "joel at streamliine.com";
> 	$subject = "Website contact";
> 	$name_field = $_POST['RealName'];
> 	$email_field = $_POST['Email'];
> 	$telephone_field = $_POST['Telephone'];
> 	$othercomments_field = $_POST['OCQ'];
> 	$headers = "From: realaddress at realsite.com";
> 	$headers .= "Cc: spinhead at gmail.com";
> 	$headers .= "Reply-To: realaddress at realsite.com";
> 	$body = "From:\n    $name_field\n\nEmail:\n
> $email_field\n\nPhone:\n    $telephone_field\n\nOther Comments or
> Questions:\n    $othercomments_field\n";
> 	mail($to, $subject, $body, $headers);
> }
> ?>
>
> I rarely use PHP (I'm learning, I promise) so I'm sure I'm missing
> something simple and obvious.
>
> thanks
>
> joel
>   

Hi Joel, welcome to php!

I believe you'll need end of line marks after the headers (From, CC, 
Reply-To, etc). On many systems "\r\n" will accomplish this. Might I 
also suggest you use the PHPMailer class 
(http://phpmailer.sourceforge.net/)?

-Nick




More information about the thelist mailing list