我試圖通過我的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
任何幫助是極大的讚賞。
您的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