Link to home
Start Free TrialLog in
Avatar of OldHatt45
OldHatt45

asked on

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
Avatar of DooDah
DooDah



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";
Avatar of hielo
>>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" .
Avatar of OldHatt45

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hielo,

Thank You!
The points are yours.

OldHatt45