[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Add CC & Bcc when Using phpmailer

Posted on 2010-01-04
5
Medium Priority
?
9,576 Views
Last Modified: 2013-11-10
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
0
Comment
Question by:OldHatt45
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:DooDah
ID: 26174368


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
 
LVL 82

Expert Comment

by:hielo
ID: 26174530
>>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
 

Author Comment

by:OldHatt45
ID: 26175026
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
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 26175175
>> 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
 

Author Comment

by:OldHatt45
ID: 26175441
Hielo,

Thank You!
The points are yours.

OldHatt45
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question