Add CC & Bcc when Using phpmailer

Trying to figure out how to use "CC" and "Bcc" when NOT On Win32 and NOT using SMTP as the transport for phpmailer.

Would really appreciate some help on this.
I'm not sure if I need to use "Headers"???
Would appreciate seeing the code for doing this.

Thanks
OldHatt45
OldHatt45Asked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
>> when NOT On Win32 and NOT using SMTP as the transport for phpmailer
So what are you using?

http://phpmailer.worxware.com/index.php?pg=methods
AddCC:
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

So it should work in non-win32. At any rate if you are using:
IsMail() and AddCC() doesn't work try:
addCustomHeader("CC: email@comapany.com")
0
 
DooDahCommented:


You will need to download the classes from http://phpmailer.sourceforge.net/ and then use some code like this :

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password

$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@site.com","Josh Adams");
$mail->addBCC("joe@site.com","Joe Tailer");

$mail->Subject = "Here is the subject";
$mail->Body = "This is the body";


if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
0
 
hieloCommented:
>>I'm not sure if I need to use "Headers"???
Yes!
Look at example #2 on the manual page:
http://us2.php.net/manual/en/function.mail.php

That examples uses:
'Reply-To: webmaster@example.com' . "\r\n" .

You will need to change it to:
'CC: webmaster2@example.com' . "\r\n" .
'Bcc: webmaster3@example.com' . "\r\n" .
0
 
OldHatt45Author Commented:
DooDah,

Your response was an example from the phpmailer download file.  This I haveworking on a Win32 platform.  My Problem is that YOU CANNOT USE AddCC and Addbcc if you are not on a Win32 platform.

Hielo,
Could You please show me the code to use for AddCustomHeader (because that's what it looked like you were trying to tell me) when using phpmailer???  What you have shown me is the stock email setup when not using phpmailer.

Thanks to both so far

OldHatt45
0
 
OldHatt45Author Commented:
Hielo,

Thank You!
The points are yours.

OldHatt45
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.