无法通过使用php梨邮件的Gmail发送电子邮件()
问题描述:
我试图通过我的gmail帐户从专用Godaddy服务器发送邮件。我试图通过我公司的电子邮件服务器发送电子邮件,但Godaddy杀死了端口25而没有解决方法(grrr)。无法通过使用php梨邮件的Gmail发送电子邮件()
我已经搜索了这个including here的解决方案的高和低,但我无法发送任何电子邮件。我总是从Google获取“需要身份验证”错误。
这里是我用来发送电子邮件的代码:
include("Mail.php");
/* mail setup recipients, subject etc */
$headers["From"] = "[email protected]";
$headers["to"] = "[email protected]";
$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"] = "[email protected]";
$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:<[email protected]>
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
任何帮助是极大的赞赏。
答
解决的办法是... ...有没有解决方案,因为GoDaddy的在做阻挡。没有办法绕过它,所以我最终使用他们的'批准'邮件传递服务器。哎呀。
答
问题是下面的代码:
PEAR_Error::getCode().' '.PEAR_Error::getMessage();
使用
$result->getMessage()
和
$result->getCode()
您的GMail帐户是否设置为允许POP3? – drudge 2010-11-16 22:30:22
我可以发现的区别是,使用引用,删除引用,然后再试一次? – ajreal 2010-11-16 22:57:06
@jnpcl是的,我的帐户有pop3激活 – Patrick 2010-11-17 14:48:25