2013-01-10 102 views
1

在過去的2個小時裏,我一直在網上查看是否有其他人遇到過這個問題,而且似乎很多,bot沒有答案爲我工作。PHPMailer SMTP配置

SMTP -> FROM SERVER:220 mx.google.com ESMTP vq7sm928004oeb.13 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
The following From address failed: [email protected] 

$mail->IsSMTP(); 
$mail->SMTPDebug = 2; 
$mail->SMPTAuth = true; 
$mail->SMTPSecure = 'tls'; 
$mail->Host = "smtp.gmail.com"; 
$mail->Mailer = "smtp"; 
$mail->Port = 587; 
$mail->Username = "[email protected]"; 
$mail->Password = "password"; 

我已經試過幾乎所有設置爲PHPMailer的,但無法弄清楚發生了什麼還是走錯了,在那裏我需要照顧的任何服務器設置?

我也嘗試了正常的PHP郵件()函數,但這並不是發送郵件,雖然使用Drupal表單時它只是發送一封電子郵件。

+0

使用'$ mail-> SMTPSecure ='ssl';'l並檢查.. – 2013-01-10 11:23:19

+0

嘗試將端口更改爲25或嘗試使用非gmail帳戶。 –

+0

檢查此問題http://stackoverflow.com/questions/3477766/phpmailer-smtp-error-could-not-connect-to-smtp-host – nasirbest

回答

1

只注意到我輸入SMTP錯在這條線上$mail->SMPTAuth = true; ,糾正這個解決了我的問題。

0

在php中設置郵件可能相當困難。你有沒有嘗試使用端口= 25?

+0

同樣的問題,它總是說「從服務器:530-5.5.1需要驗證「,這不適用於Google Apps地址嗎? –

8

對於首先你必須配置正確的服務器來發送電子郵件(見gmail.com):

SMTP server address: smtp.gmail.com 
SMTP user name: Your full Gmail address (e.g. [email protected]) 
SMTP password: Your Gmail password 
SMTP port: 465 or 587 
SMTP TLS/SSL required: yes 

在PHPMailer的:

$mail->SMTPAuth = true; // There was a syntax error here (SMPTAuth) 
$mail->SMTPSecure = 'tls'; 
$mail->Host = "smtp.gmail.com"; 
$mail->Mailer = "smtp"; 
$mail->Port = 465; 
$mail->Username = "[email protected]"; 
$mail->Password = "YOUR_GMAIL_password"; 
+0

如果我用口嘗試465,我發現了以下內容: 'SMTP - >從服務器: SMTP - >從服務器: SMTP - > ERROR:EHLO不是從服務器接受: SMTP - >從服務器: SMTP - >錯誤:HELO未被服務器接受: SMTP - >注意:EOF在檢查連接時是否被捕獲以下發件人地址失敗:gmail @ domain.com' –

+1

它在端口'587'上爲我工作 –

4

我的問題是我使用了兩步驗證。所以我必須記得去我的Google帳戶的授權訪問&,然後爲我用來發送郵件的域分配一個特定於應用程序的密碼。