Dear Sir
I am using PHP Mailer for SMTP Authentication, Everything is working fine http://phpmailer.worxware.com/index.php?pg=methods
But AddCC is not working , I am using Windows 2003 Server, and it says this function works with SMTP Mailer , not with the Mail Mailer.

AddCC($address, $name = "")
string $address
string $name
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

I can't Understand this line : Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>

<?php
include("config.php");
//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();


//$body             = file_get_contents('contents.php');
//$body             = eregi_replace("[\]",'',$body);



$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >30 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows30p = mysql_num_rows($result);  //30+

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=30 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=22 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows2230 = mysql_num_rows($result); // 22-30

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=21 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=15 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows1521 = mysql_num_rows($result); // 15-21

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=14 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=1 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows115 = mysql_num_rows($result); // 1-15



 $body			= "<html><body style='margin: 10px;'>
<div style='width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;'>
Dear Payable/Finance <br />
Please find the attached sheet of pending payments at your end (starting from 15-21). Following is the summary of attached sheet.  <br />
<table  border='1' bordercolordark='#000000' cellpadding='10'>
  	<tr>
    <td width='42%' style='background: #eee;'><strong>Total Days</strong></td>
    <td width='58%' style='background: #eee;'><strong>No. of Payments</strong></td>
	</tr>
	
	 	 	<tr>
    <td width='42%'>0-14</td>
    <td width='58%'>$num_rows115</td>
	</tr>
		
		<tr>
    <td width='42%'>15-21</td>
    <td width='58%'>$num_rows1521</td>
	</tr>
	
		 	<tr>
    <td width='42%'>22-30</td>
    <td width='58%'>$num_rows2230</td>
	</tr>
	
		 	<tr>
    <td width='42%'>30+</td>
    <td width='58%'>$num_rows30p</td>
	</tr>

</table>
<br />
Engineering Database:<br />
Generated Automatically by Engineering Database<br />
Please, DO NOT Reply to this System Generated Email.<br /></div></body></html>"; 



$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "*******"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "********"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "*****"; // SMTP account username
$mail->Password   = "*****";        // SMTP account password

$mail->SetFrom('edb@****.com.pk', 'Engineering Databse');

$mail->AddReplyTo("*****@****.com.pk","First Last");

$mail->Subject    = "Engineering Database Report";

//$mail->AddEmbeddedImage('phpmailer.gif', 'phpmailer', 'phpmailer.gif '); use this in $body for viewing <img src='cid:phpmailer' alt='phpmailer' />

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);


$mail->AddAddress("****@****.com.pk", "Furqan");

$mail->AddCC('****@****.com.pk', 'First Person'); // this not working


$mail->AddAttachment("Excel/LongOutstandings.xlsx");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

</body>
</html>

For cc on your own you may try

$mail->addCustomHeader("Cc: {$yourccmailid1},{$yourccmailid2}");

For cc on your own you may try

$mail->addCustomHeader("Cc: {$yourccmailid1},{$yourccmailid2}");

By using above line it shows in cc when "to" receive email , but "cc"
email did not get email, it just show in cc

Email working Fine, I can also add Cc using custom Header, But Email is not sending to Cc Addresses

Also, I want to know that I am using Windows 2003 Server and XAMPP with PHP Mailer and SMTP Authentication. Why its giving error

this function works with the SMTP mailer on win32, not with the "mail" mailer.

Anyone can have any idea about it, I am using win32 but even though its not working

I am here with a hope someone can give me any clue about my issue.

I am posting simplest code here to send mail. It does not require to use any class

<?php

	$headers= "MIME-Version: 1.0\n";
	$headers.="Content-type: text/html; charset=iso-8859-1\n";
	$headers.="Cc: abc@yahoo.com,pqr@gmail.com\n";	
	$headers.="Bcc: a1234@yahoo.com,xyz@gmail.com\n";	
	$subject = "sample mail";
	$message="<br><b>this is just a sample</b>.";
	
	$message.="<br><br>This is system generated message. Please do not reply.";						
         $sendmail = mail("toemail@yahoo.com", $subject, "<html><body>".$message."</body></html>", $headers);
		

?>

I have used PHPMailer's AddCC for a long time without problems on a linux/cpanel server. I changed recently to a linux/plesk server and I now have this problem.

AddAddress works but not AddCC. My workaround is to use AddAddress instead of AddCC.

without phpmailer..it gives an error at line number 11(mail function)..i have done settings in php.ini file also..now what to do??
thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.