I have read the similar posts about this problem but can't quite get my head around what I am doing wrong here. The 'To' email is received ok.
However, I can not get the 'CC' email to send when using the following script. Any help would be much appreciated.
// Require Pear Mail Packages
require_once ("Mail.php");
require_once ("Mail/mime.php");
require_once ("Mail/mail.php");
$crlf = "\n";
$from = "Company <admin@example.com>";
$to = $purchasersName . "<" . $purchasersEmail . ">";
$cc = "Company <admin@example.com>";
$subject = "Company Order Confirmation";
$host = "localhost";
$port = "25";
$username = "the username";
$password = "the password";
$hdrs = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Subject' => $subject);
$mime = new Mail_mime(array('eol' => $crlf));
$mime->setHTMLBody($mailBody);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$smtp =& Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $hdrs, $body);
This comment is in the pear docs on this page
http://pear.php.net/manual/en/package.mail.mail.send.php
(If you want other options, you could try http://swiftmailer.org , I have used that on lots of projects now)
Note by: arminfrey@gmail.com 2007-07-08 05:13 UTC In order to send e-mail to cc or bcc with smtp you have to list the cc e-mail address both as a recipient (which decides where the e-mail is sent) and in the cc header, which tells the mail client how to display it.
Here is the code I use:
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.