I have been able to send email through gmail from PHP for a long time, and not sure what changed but now I can't. I created a testing page and have the following code list and I am still getting an error. Does anyone see anything that is wrong?
Error: Failed to set sender: @ [SMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. fj1sm16678796oeb.5 - gsmtp)]
$from = "no-reply@mydomain.com <no-reply@mydomain.com>";
$to = "brad@mydomain.com <brad@mydomain.com>";
$subject = "Welcome to SITENAME!";
$crlf = "\n";
$html = "<h1> This is HTML </h1>";
$headers = array('From' => $from,
'To' => $to,
'Subject' => $subject);
$host = "ssl://smtp.gmail.com"; // try this one to use ssl
$port = 465;
$username = "no-reply@mydomain.com";
$password = "MyPasswordHere";
$mime = new Mail_mime(array('eol' => $crlf)); //based on pear doc
$mime->setHTMLBody($html);
$body = $mime->getMessageBody(); //based on pear doc above
$headers = $mime->headers($headers);
$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 $mail->getMessage();
} else {
echo "Message sent successfully!";
}
echo "\n";