|
Posted by Shelly on 10/26/06 10:53
"George Doka" <serious@cerius.com> wrote in message
news:fj%%g.37052$P7.7590@edtnps89...
> Hi, I'm an html-guy getting his feet wet in PHP.
> I DL'd a simple server-side mail script from the 'net and have been trying
> to modify it so it includes a CC and BCC function.
>
> the form page contained "to", "name", "from" and "subject" input fields; I
> added "CC" and "BCC" inputs, hoping that PHP would say, "ah, yes,
> indeed..." But no luck.
>
> I've pasted the main form-page code and the main form-processor code
> below; if it's at all possible to include CC and BCC functions in PHP
> mailers, can anyone help me with this?
>
> Thanks,
> GD
>
>
> Here's the form page code:
> ============================
>
> <form name=sds action="mailer.php" METHOD="POST" onsubmit="return
> check()">
>
> <font color=<? echo($FONTCOLOR); ?>><i>"To" Email:
> </font><td><input type="text" name="to" size=27>
>
>
> <!-- added CC and BCC experiment -->
> <font color=<? echo($FONTCOLOR); ?>>"CC" Email??:
> </font><td><input type="text" name="cc" size=27>
> <font color=<? echo($FONTCOLOR); ?>>"BCC" Email??:
> </font><td><input type="text" name="bcc" size=27>
> <!-- end addition -->
>
>
> <font color=<? echo($FONTCOLOR); ?>>"To" Name: *
> </font><td><input type="text" name="name" size=27>
> <font color=<? echo($FONTCOLOR); ?>>"From"
> Email:</font><td><input type="text" name="from" size=27>
> <font color=<? echo($FONTCOLOR); ?>>Subject:</font><br><br><td><input
> type="text" name="subject" size=29>
> <? echo($FONTCOLOR);?> ><b>Message: * </b></font><br> <textarea
> name="messagebody" rows=13 cols=55 wrap="physical"></textarea>
> <input type="submit" value="Send">
>
>
>
> ===========================
>
> Here's the main 'guts' of the mail processor:
>
> =============================
>
> <?php
>
> /* recipients */
> $to1 = $_POST['to'];
>
> /* message */
> $name1 = $_POST['name'];
> $from1 = $_POST['from'];
> $subject1 = $_POST['subject'];
> $messagebody1= $_POST['messagebody'];
>
> /* add cc and bcc var's */
>
> $cc1 = $_POST['cc'];
> $bcc1 = $_POST['bcc'];
>
> $messagebody1= str_replace("\\\\","",$messagebody1);
> $messagebody1= str_replace("\'","'",$messagebody1);
> $messagebody1= str_replace("\\\"","\"",$messagebody1);
> $message1 .= $messagebody1."\r\n";
> $subject1 = "$subject1";
>
> /* added this: */
>
> $message1 .= "CC :".$cc1."\r\n";
> $message1 .= "BCC :".$bcc1."\r\n";
>
> /*end addition */
This is the wrong place to add the $cc1 and $bcc1 information. It should be
added to the headers.
> /* To send HTML mail, you can set the Content-type header. */
>
> $headers1 = "MIME-Version: 1.0\r\n";
> $headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
>
> /* additional headers */
>
> $headers1 .= "To: ".$to1."\r\n";
> $headers1 .= "From: ".$from1."\r\n";
> $headers1 .= "Reply-To: ".$from1."\r\n";
> $headers1 .= "Cc: \r\n";
This is where you should be adding the $cc1 information.
$headers1 .= "Cc: " . $cc1 . "\r\n";
Shelly
[Back to original message]
|