Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP processing cc form field (Windows Platform) 1

Status
Not open for further replies.

jollydonkey

Technical User
Sep 5, 2008
23
CA
Hello,

I've got a peculiar situation.

I have a php form processing script (Windows platform) that is supposed to send a copy of a form submission via email to cc recipients. The script reaches everyone in the to: field, however, not on the cc: field.

On a Linux platform, this problem does not seem to occur and all cc recipients receive a copy of the email.

Here is the code:
Code:
$email  = $_POST['email'];
$cc     = $_POST['cc'];
$ccCopy = $cc.",".$email;
$topic = $_POST['topic'];
$summary = $_POST['summary'];

$to = 'me1@me.com, me2@me.com, me3@me.com';
$subject = "$topic_output";
$message = "$summary_output";

$headers = array('From' => $email, 'To' => $to, 'CC' => $ccCopy, 'Subject' => $subject);

$host = "smtp.me.com";
$username = "smtp@me.com";
$password = "qwerty";

$smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $message);

Any reasons why cc recipients may not be getting a copy of the submission? Note, interestingly, cc recipients are listed properly in the cc field (they just don't get a copy). Note, it's been confirmed that messages are not getting trapped by a spam filter.

Thanks!
jd.


 
It does - I also found this:

My script is now working...key to remember I guess is that we have control over the headers, including the To: header.

In case anyone else experienced the same problem, below is the post of the solution from the above forum.

That said, jpadie - you are the best! Your direction/solutions are always on the money - thank you for the learning you've provided me and this forum!

Code:
It seems that the Recipients decides where to send the e-mail and the
headers decide how to display it.

The simple solution is that you add all the addresses to $recipients.

Here is the code I used:

$to = 'to@example.com';
$cc = 'cc@example.com';
$recipients = $to.", ".$cc;
$headers['From']    = 'from@example.com';
$headers['To']      = $to;
$headers['Subject'] = 'Test message';
$headers['Cc']	    = 'cc@example.com';
$headers['Reply-To'] = 'from@example.com';

$send = $mail->send($recipients, $headers, $body);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top