I am trying to send an email via GMail's SMTP server from a PHP page, but I get this error:
(我正在尝试从PHP页面通过GMail的SMTP服务器发送电子邮件,但出现此错误:)
authentication failure [SMTP: SMTP server does no support authentication (code: 250, response: mx.google.com at your service, [98.117.99.235] SIZE 35651584 8BITMIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)]
(身份验证失败[SMTP:SMTP服务器不支持身份验证(代码:250,响应:mx.google.com,为您提供服务,[98.117.99.235]大小为35651584 8位MIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)])
Can anyone help?
(有人可以帮忙吗?)
Here is my code: (这是我的代码:)
<?php
require_once "Mail.php";
$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Hi!";
$body = "Hi,
How are you?";
$host = "smtp.gmail.com";
$port = "587";
$username = "[email protected]";
$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("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
ask by skb translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…