我在使用PHPMailer和SSL在本地計算機上發送電子郵件時遇到問題(無需使用SSL即可正常工作),並且我不知道從哪裏開始找到哪裏錯誤來自於。PHPMailer將不會使用SSL發送,但Outlook將會
錯誤:
2015-02-08 01:13:29 Connection: opening to ssl://mail.mydomain.com:465, t=300, opt=array () 2015-02-08 01:13:29 SMTP ERROR: Failed to connect to server: (0) 2015-02-08 01:13:29 SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed.
這裏是我的代碼,我使用派:
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.mydomain.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'xxxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->addAddress('[email protected]'); // Add a recipient
這是我曾嘗試/發現:
- 相同的代碼工作正常從我的服務器(電子郵件服務器也存儲在其中)
- 沒有SSL,我可以找到來自我的本地主機或服務器的電子郵件。
- 我可以使用來自家庭計算機和PHPMailer的帶有SSL的gmail帳戶發送郵件。
- 使用與上述代碼相同的設置,我可以在家中使用Microsoft Outlook發送/接收消息(詢問我是否接受證書)。
- 我試圖沖洗DNS(使用
ipconfig /flushdns
),但它什麼也沒做。
我真的不知道從哪裏開始尋找,因爲我可以通過ssl使用gmail帳戶發送消息,但不能使用我自己的帳戶,但是如果使用outlook,我可以。
任何想法,我搞砸了?
編輯:
NSLOOKUP結果:
C:\Users\xxx>nslookup mail.xxxx.com
Server: UnKnown
Address: 192.168.1.1
Non-authoritative answer:
Name: xxxx.com
Address: 110.232.yyy.zzz (this is correct)
Aliases: mail.xxxx.com
$ openssl s_client -starttls smtp -crlf -connect mail.xxxx.com:465
CONNECTED(00000003)
$ openssl s_client -crlf -connect mail.xxxx.com:465
CONNECTED(00000003)
depth=1 C = US, ST = Illinois, L = Chicago, O = "Trustwave Holdings, Inc.", CN = "Trustwave Organization Validation CA, Level 2", emailAddress = [email protected]
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/CN=*.zuver.net.au/O=Zuver Pty Ltd/L=Narre Warren/ST=VIC/C=AU
i:/C=US/ST=Illinois/L=Chicago/O=Trustwave Holdings, Inc./CN=Trustwave Organization Validation CA, Level 2/[email protected]
1 s:/C=US/ST=Illinois/L=Chicago/O=Trustwave Holdings, Inc./CN=Trustwave Organization Validation CA, Level 2/[email protected]
i:/C=US/O=SecureTrust Corporation/CN=SecureTrust CA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIFLTCCBBWgAwIB...
-----END CERTIFICATE-----
subject=/CN=*.zuver.net.au/O=Zuver Pty Ltd/L=Narre Warren/ST=VIC/C=AU
issuer=/C=US/ST=Illinois/L=Chicago/O=Trustwave Holdings, Inc./CN=Trustwave Organization Validation CA, Level 2/[email protected]
---
No client certificate CA names sent
---
SSL handshake has read 3822 bytes and written 624 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : DHE-RSA-AES256-GCM-SHA384
Session-ID: 150CD8E826D73DD132572E...
Session-ID-ctx:
Master-Key: CCB6C3F...
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 200 (seconds)
TLS session ticket:
0000 - 57 3a ...
Start Time: 1423438080
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
---
220-zzz.zuver.net.au ESMTP Exim 4.84 #2 Mon, 09 Feb 2015 10:27:59 +1100
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
你使用的是Apache嗎? – 2015-02-08 01:35:19
@noob是的,我忘了提及php_openssl.dll也啓用。 – tgun926 2015-02-08 01:41:26
你嘗試過端口587嗎? – 2015-02-08 01:42:49