我试图通过我的gmail帐户从一个专用的Godaddy服务器发送邮件。我试图通过我公司的电子邮件服务器发送电子邮件,但Godaddy在没有解决方法(grrr)的情况下杀死了端口25。
我想方设法想办法解决这个问题
including here
但我不能发送任何电子邮件。我总是从谷歌那里得到一个“需要验证”的错误。
以下是我用来发送电子邮件的代码:
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.";
以下是pear邮件的回复:
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
任何帮助都非常感谢。