View Full Version : mail problem cc'ing

11-02-2012, 06:24 AM

I send a set up email when someone registers on my site. I also cc this email to support@mysite.com so I can monitor registrations to check for spam.

The email goes through to the user just fine, but I'm not getting cc'd on it anymore (it was working fine a while ago, and I can't recall changing the mail set up at all).

It's using Pear and Gmail.

Can anyone see a problem in the code?

$base = "mysite.com";

require_once "Mail.php";

$subject = "blah";
$body = "blah blah";
$from = "support@".$base;
$to = "$email";
$cc = "support@".$base;
$recipients = $to.", ".$cc;

$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "bladiblah";//google apps username
$password = "blahdiblahblah";//google apps pass

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Cc' => $cc);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($recipients, $headers, $body);

if (PEAR::isError($mail))
//error stuff

Thanks for taking a look.

11-02-2012, 02:03 PM
To be honest if it just suddenly stopped working then its more likely to be a spam filter on your server that has got fed up with emails using the same template and decided they must all be spam.

There is no other reason for them not to be arriving if you've not touched the code.

To be safe, you could always try using phpmailer but i don't think you're going to see any change in the outcome.

11-05-2012, 03:36 AM
Turns out it's something Google changed in Google Apps. If you send an email to yourself, it skips the inbox and goes straight to sent.

The best you can do to get around it is set up a new contact in CONTACTS, set it to the email that you are cc'ing yourself on (the one with the same domain as your account email), and then it gets sent to your main account email address, although it shows up as being read (not bold in my email program). I set up a filter for the cc email addy so that it gets a star, to try and make it stand out a little since it's delivered as read.