redbrad0 Posted April 29, 2011 Share Posted April 29, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/235084-sending-mail-through-smtp-is-not-sending-to-cc-or-bcc-email-address/ Share on other sites More sharing options...
redbrad0 Posted May 7, 2011 Author Share Posted May 7, 2011 Can anyone help with this? Quote Link to comment https://forums.phpfreaks.com/topic/235084-sending-mail-through-smtp-is-not-sending-to-cc-or-bcc-email-address/#findComment-1211833 Share on other sites More sharing options...
efficacious Posted May 7, 2011 Share Posted May 7, 2011 just set each email address in the first parameter seperated by commas http://myphpform.com/php-form-multiple-recipients.php ^ examples Quote Link to comment https://forums.phpfreaks.com/topic/235084-sending-mail-through-smtp-is-not-sending-to-cc-or-bcc-email-address/#findComment-1211835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.