[英]unable to send email through gmail with php pear mail()
I am attempting to send mail through my gmail account from a Dedicated Godaddy server. 我正在尝试通过Gmail帐户从专用的Godaddy服务器发送邮件。 I have attempted to send email through my company's email server but Godaddy kills port 25 with no workaround (grrr).
我试图通过公司的电子邮件服务器发送电子邮件,但是Godaddy取消了端口25,但没有解决方法(grrr)。
I have searched high and low for a solution to this including here but am unable to send any emails. 我已经在上下搜索了解决方案, 包括此处,但无法发送任何电子邮件。 I always get an 'Authentication Required' error from google.
我总是从Google收到“需要身份验证”错误。
Here is the code I use to send the email: 这是我用来发送电子邮件的代码:
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.";
Here is the response from pear 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
Any help is greatly appreciated. 任何帮助是极大的赞赏。
The solution is... there is no solution since Godaddy was doing blocking. 解决的方法是...自从Godaddy进行封锁以来,没有任何解决方法。 No way to get around it so I ended up using their 'approved' mail delivery server.
无法解决它,所以我最终使用了他们的“批准”邮件传递服务器。 grrr.
rr
The problem is following code: 问题是以下代码:
PEAR_Error::getCode().' '.PEAR_Error::getMessage();
Use 采用
$result->getMessage()
and 和
$result->getCode()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.