January 5, 200620 yr I was hoping someone could tell me how to include a cc email in the following code from FmWebSchool: <? $mailto = '[email protected]' ; $subject = "Feedback Form" ; $formurl = "http://www.yourwebsite.net/page1.htm" ; $errorurl = "http://www.yourwebsite.net/emailerror.htm" ; $thankyouurl = "http://www.yourwebsite.net/emailcomplete.htm" ; $firstname = $_POST['firstname'] ; $lastname = $_POST['lastname'] ; $email = $_POST['email'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } $messagetext =" nn"."firstname=".$firstname ."nlastname=".$lastname."nemail=".$email."nn n" ; mail($mailto, $subject, $messagetext, "From: "$name" <$email>nReply-To: "$name" <$email>nX-Mailer: chfeedback.php 2.01" ); header( "Location: $thankyouurl" ); exit ; ?> Thanks in advance for your help - Sam
January 5, 200620 yr Try this: mail($mailto, $subject, $messagetext, "From: "$name" <$email>nReply-To: "$name" <$email> nCc: [email protected] nX-Mailer: chfeedback.php 2.01:" ); Good Luck. Garry
January 5, 200620 yr Author Thanks Garry, You code works great. I just realized that I wanted a blind cc. Do you have the code for that. You always are a great help - Thank you - Sam
January 5, 200620 yr I think it is just: nBcc: [email protected] Good Luck. Garry p.s. You will find information about the PHP mail() function here: http://au3.php.net/manual/en/function.mail.php
January 11, 200620 yr Gary, I have the following universal email script, but for some reason the 'Cc' doesn't work. The headers print out as if the 'Cc' should be working, but no 'Cc' is ever received. Any thoughts on what might be missing? function sendEmailWithSockets ($toName, $toEmail, $subject, $message) { global $SMTPServer, $SMTPPort, $emailFromName, $emailFromAddr, $contactEmailAddr; $connect = fsockopen($SMTPServer, $SMTPPort, $errno, $errstr, 30) or die("$errno: $errstr"); $rcv = fgets($connect, 1024); fputs($connect, "HELO {$_SERVER['SERVER_NAME']}rn"); $rcv = fgets($connect, 1024); fputs($connect, "MAIL FROM:{$emailFromAddr}rn"); $rcv = fgets($connect, 1024); fputs($connect, "RCPT TO:{$toEmail}rn"); $rcv = fgets($connect, 1024); fputs($connect, "DATArn"); $rcv = fgets($connect, 1024); fputs($connect, "Subject: $subjectrn"); fputs($connect, "From: {$emailFromName} <{$emailFromAddr}>rn"); fputs($connect, "To: {$toName} <{$toEmail}>rn"); fputs($connect, "Cc: Mark Lindal rn"); fputs($connect, "X-Sender: <{$emailFromAddr}>rn"); fputs($connect, "Return-Path: <{$emailFromAddr}>rn"); fputs($connect, "Errors-To: <{$emailFromAddr}>rn"); fputs($connect, "X-Mailer: PHPrn"); fputs($connect, "X-Priority: 3rn"); fputs($connect, "Content-Type: text/html; charset=utf-8rn"); fputs($connect, "rn"); fputs($connect, stripslashes($message)." rn"); fputs($connect, ".rn"); $rcv = fgets($connect, 1024); fputs($connect, "RSETrn"); $rcv = fgets($connect, 1024); fputs ($connect, "QUITrn"); $rcv = fgets ($connect, 1024); fclose($connect); }
January 11, 200620 yr I've never used the sockets method, I just use the mail() function. However, try this line: fputs($connect, "Cc: [email protected]"); I took out the name and the <>. Good Luck. Garry
January 12, 200620 yr Interesting. The headers display correctly, but still no CC'd email is received. When I take the message and do a reply-all, the cc'd address is mysteriously dropped. I think I read somewhere (php.net) where the windows version was having problems with cc and bcc.
Create an account or sign in to comment