【发布时间】:2011-05-11 02:23:39
【问题描述】:
我正在尝试通过我的 gmail 帐户从专用 Godaddy 服务器发送邮件。我试图通过我公司的电子邮件服务器发送电子邮件,但 Godaddy 没有解决方法 (grrr) 就杀死了端口 25。
我已经到处搜索了这个including here 的解决方案,但我无法发送任何电子邮件。我总是从 google 收到“需要身份验证”错误。
这是我用来发送电子邮件的代码:
include("Mail.php");
/* mail setup recipients, subject etc */
$headers["From"] = "xxxxx@gmail.com";
$headers["to"] = "yyyyy@hotmail.com";
$headers["subject"] = "User feedback";
$mailmsg = "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "ssl://smtp.gmail.com";
$smtpinfo["port"] = 465;
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "xxxxx@gmail.com";
$smtpinfo["password"] = "xxxxxx";
$smtpinfo["debug"] = true;
/* Create the mail object using the Mail::factory method */
// $mail_object =& Mail::factory("smtp", $smtpinfo);
// EDIT -- removed reference
$mail_object = Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$result = $mail_object->send($recipients, $headers, $mailmsg);
if(PEAR::isError($result))
{
echo "\nerror sending mail: ".PEAR_Error::getCode().' '.PEAR_Error::getMessage();
}
else
echo "\nSuccessfully sent mail.";
这是梨邮件的回复:
DEBUG: Recv: 250-mx.google.com at your service, [208.109.190.226]
DEBUG: Recv: 250-SIZE 35651584
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250-AUTH LOGIN PLAIN XOAUTH
DEBUG: Recv: 250 ENHANCEDSTATUSCODES
DEBUG: Send: MAIL FROM:<xxxxx@gmail.com>
DEBUG: Recv: 530-5.5.1 Authentication Required. Learn more at
DEBUG: Recv: 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 t35sm1037116qco.30
Fatal error: Using $this when not in object context in /usr/share/php/PEAR.php on line 970
非常感谢任何帮助。
【问题讨论】:
-
您的 GMail 帐户是否设置为允许 POP3?
-
我能发现的区别,是引用的使用,删除引用,然后再试一次?
-
@jnpcl 是的,我的帐户已激活 pop3
-
@ajreal 我删除了我找到的唯一参考(在 Mail::factory)行,但仍然得到相同的错误
-
我与 Godaddy 交谈过,他们不会给我服务器上被阻止端口的列表。我是个白痴,我认为这是一个专用服务器,我不必担心端口被阻塞。我在 a2hosting 服务器上运行此脚本并成功完成。我正在接受 Godaddy 允许我通过他们自己的中继主机发送电子邮件的唯一方式,这可能会破坏我的服务...... grrr
标签: php email authentication gmail pear