我在使用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