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 = "redbrad0@domain.com";
$emailCC = "brad@domain.com";
$emailBCC = "events@domain.com";
$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'] = "events@domain.com";

$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' => 'events@domain.com',
     '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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.