View Full Version : PHP to SMTP email script

11-19-2010, 01:36 PM

I am using the script below to send an email to my main pop3 email, and cc to my yahoo mail.

The message never makes it to yahoo, any idea why?

Kind Regards
Nick Burrett


require_once "Mail.php";

$from = "Nick Burrett <xxx>";
$to = "Nick Burrett <xxx>";
$subject = "Test message from Gmail";
$cc = "Nick Burrett <xxx>";
$body = "Test message from Gmail";

$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "xxx";
$password = "xxx";

$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($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");


11-19-2010, 02:08 PM
it seems to me that I had this issue before, try removing the name and brackets

$cc = "Nick Burrett <xxx>";

and just use the email address and see if that works. I think that I had this issue and found that I couildn't get the name/email combo working but just the email.