2016-01-18 71 views
1

我安裝了XAMPP服務器,現在我試圖通過Gmail服務器發送本地電子郵件。要做到這一點,我也跟着this link和改變了我的php.ini並sendmail.ini如下:通過Xampp發送本地電子郵件時發生Gmail錯誤(必須發出STARTTLS命令)

的php.ini

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
SMTP = smtp.gmail.com 
; http://php.net/smtp-port 
smtp_port = 587 

; For Win32 only. 
; http://php.net/sendmail-from 
sendmail_from = [email protected] 

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

; Force the addition of the specified parameters to be passed as extra parameters 
; to the sendmail binary. These parameters will always replace the value of 
; the 5th parameter to mail(), even in safe mode. 
;mail.force_extra_parameters = 

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename 
mail.add_x_header = Off 

; Log all mail() calls including the full path of the script, line #, to address and headers 
;mail.log = "C:\xampp\php\logs\php_mail.log" 

sendmail.ini

; configuration for fake sendmail 

; if this file doesn't exist, sendmail.exe will look for the settings in 
; the registry, under HKLM\Software\Sendmail 

[sendmail] 

; you must change mail.mydomain.com to your smtp server, 
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) 
; emails delivered via IIS's pickup directory cause sendmail to 
; run quicker, but you won't get error messages back to the calling 
; application. 

smtp_server=smtp.gmail.com 

; smtp port (normally 25) 

smtp_port=587 

; the default domain for this server will be read from the registry 
; this will be appended to email addresses when one isn't provided 
; if you want to override the value in the registry, uncomment and modify 

;default_domain=local 

; log smtp errors to error.log (defaults to same directory as sendmail.exe) 
; uncomment to enable logging 

error_logfile=error.log 

; create debug log as debug.log (defaults to same directory as sendmail.exe) 
; uncomment to enable debugging 

debug_logfile=debug.log 

; if your smtp server requires authentication, modify the following two lines 

[email protected] 
auth_password=xxx 

; if your smtp server uses pop3 before smtp authentication, modify the 
; following three lines 

;pop3_server= 
;pop3_username= 
;pop3_password= 

; to force the sender to always be the following email address, uncomment and 
; populate with a valid email address. this will only affect the "MAIL FROM" 
; command, it won't modify the "From: " header of the message content 

[email protected] 

; sendmail will use your hostname and your default_domain in the ehlo/helo 
; smtp greeting. you can manually set the ehlo/helo name if required 

;hostname=localhost 

有了這些設置,我會從Gmail服務器得到以下錯誤:

16/01/18 20:47:28 ** Connecting to smtp.gmail.com:587 
16/01/18 20:47:28 ** Connected. 
16/01/18 20:47:28 << 220 smtp.gmail.com ESMTP w80sm17190895wme.17 - gsmtp<EOL> 
16/01/18 20:47:28 >> EHLO SamClauw<EOL> 
16/01/18 20:47:28 << 250-smtp.gmail.com at your service, [213.118.20.101]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL> 
16/01/18 20:47:28 ** Authenticating as [email protected] 
16/01/18 20:47:28 >> MAIL FROM: <[email protected]><EOL> 
16/01/18 20:47:28 << 530 5.7.0 Must issue a STARTTLS command first. w80sm17190895wme.17 - gsmtp<EOL> 
16/01/18 20:47:28 ** Disconnecting from smtp.gmail.com:587 
16/01/18 20:47:28 ** Disconnected. 
16/01/18 20:47:28 ** Disconnected. 
16/01/18 20:47:28 ** Must issue a STARTTLS command first. w80sm17190895wme.17 - gsmtp<EOL> 

正如您所看到的:我已經建立了連接,但在此之後,STARTTLS命令或其他問題出現了問題。

我一派,我嘗試了很多:

  • 的XAMPP
  • SMTP端口25和465
  • SSL管理員權限://smtp.gmail.com代替smtp.gmail.com
  • 在我的Gmail帳戶
  • 較低的安全...

但沒有日。正在幫助。有沒有人有同樣的問題,可以解決這個問題?我應該改變什麼樣的設置,以便最終可以工作?

謝謝;)

+0

你有沒有得到這個工作?我已經嘗試了相同的列表以使其正常工作,但我仍然無法發送電子郵件。希望這篇文章有答案,但你已經嘗試了我所做的一切,甚至降低了我的Gmail帳戶的安全性。 – mtpultz

回答

0

我曾經有同樣的問題,所以我試圖通過TLS和工作連接。 這是從我的郵件我的輸出:

$mail->SMTPSecure = 'tls'; 
$mail->Host = 'smtp.gmail.com'; 
$mail->Port = 587; 
$mail->SMTPOptions = array(
    'ssl' => array(
     'verify_peer' => false, 
     'verify_peer_name' => false, 
     'allow_self_signed' => true 
    ) 
); 

我使用PHPMailer的(https://github.com/PHPMailer/PHPMailer/),所以你應該嘗試連接到主機:TLS://smtp.gmail.com:587。

+0

當我將SMTP的php.ini值更改爲「tls://smtp.gmail.com」,並將smtp_server的sendmail.php值更改爲「tls://smtp.gmail.com」時,我得到了以下錯誤在我的調試日誌中:連接到tls:25 - 16/01/20 19:21:50 **斷開連接。 - 16/01/20 19:21:50 **斷開連接。 - 16/01/20 19:21:50 **斷開連接。 - 16/01/20 19:21:50 ** Socket Error#11004 。它似乎不適用於我的情況。 PHPMailer不是XAMPP用來發送本地電子郵件的那個嗎? – Sam

+0

你必須使用端口587而不是端口25 嘗試:tls://smtp.gmail.com:587 – BiGGiE0344

相關問題