Jump to content

Sending mail through SMTP is not sending to CC or BCC email address


redbrad0

Recommended Posts

From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code?

 

$currentTime = time();

$emailTo = "[email protected]";
$emailCC = "[email protected]";
$emailBCC = "[email protected]";
$emailSubject = "TEST Email at (" . $currentTime . ")";
$emailBody = "This is the body of the email";

$headers = array();
if (!empty($emailTo))
$headers['TO'] = $emailTo;
if (!empty($emailCC))
$headers['CC'] = $emailCC;
if (!empty($emailBCC))
$headers['BCC'] = $emailBCC;
if (!empty($emailSubject))
$headers['Subject'] = $emailSubject;
$headers['From'] = "[email protected]";

$mime = new Mail_mime("\n");
$mime->setTXTBody($emailBody);
$body = $mime->get();
$headers = $mime->headers($headers);

$mail = Mail::factory('smtp',
   array ('host' => 'ssl://smtp.gmail.com',
     'auth' => true,
     'port' => 465,
     'username' => '[email protected]',
     'password' => 'thepasswordhere'));

try {
  $result = $mail->send($emailTo, $headers, $emailBody);
} catch (TixException $ex) {      
  echo "<font color=red>Error:" . $ex->getCode() . "</font><br>";
}

echo "Emailed at (" . $currentTime . ")<br>";
die;

 

[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.