我试图通过Gmail的SMTP服务器从一个PHP页面发送电子邮件,但是我得到了这个错误:
身份验证失败[SMTP:SMTP服务器不支持身份验证(代码:250,响应: at your service,[98.117.99.235]SIZE 35651584 8Bitmime STARTTLS ENHANCEDSTATUSCODES PIPELINING)]
有人能帮忙吗? 下面是我的代码:<?php
require_once "Mail.php";
$from = "Sandra Sender ";
$to = "Ramona Recipient ";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "";
$port = "587";
$username = "testtest@";
$password = "testtest";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$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 successfully sent!
");
}
?>