我在php5.5测试中没遇到这么慢的问题
如果删除stream_socket_enable_crypto然后测试,它就不会那么慢
有什么好方法可以解决吗
<?php
/**
* This example shows making an SMTP connection with authentication.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtp.qq.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "304906398@qq.com";
//Password to use for SMTP authentication
$mail->Password = "munftzonbxribjdf";
//Set who the message is to be sent from
$mail->setFrom('304906398@qq.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('304906398@qq.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("测试邮件");
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
SMTPDebug,大约27秒。
2016-04-09 07:06:20 SERVER -> CLIENT: 220 smtp.qq.com Esmtp QQ Mail Server
2016-04-09 07:06:20 CLIENT -> SERVER: EHLO localhost
2016-04-09 07:06:20 SERVER -> CLIENT: 250-smtp.qq.com250-PIPELINING250-SIZE 73400320250-STARTTLS250-AUTH LOGIN PLAIN250-AUTH=LOGIN250-MAILCOMPRESS250 8BITMIME
2016-04-09 07:06:20 CLIENT -> SERVER: STARTTLS
2016-04-09 07:06:20 SERVER -> CLIENT: 220 Ready to start TLS
2016-04-09 07:06:47 CLIENT -> SERVER: EHLO localhost
2016-04-09 07:06:47 SERVER -> CLIENT: 250-smtp.qq.com250-PIPELINING250-SIZE 73400320250-AUTH LOGIN PLAIN250-AUTH=LOGIN250-MAILCOMPRESS250 8BITMIME
2016-04-09 07:06:47 CLIENT -> SERVER: AUTH LOGIN
2016-04-09 07:06:47 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-04-09 07:06:47 CLIENT -> SERVER: MzA0OTA2Mzk4QHFxLmNvbQ==
2016-04-09 07:06:47 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2016-04-09 07:06:47 CLIENT -> SERVER: bXVuZnR6b25ieHJpYmpkZg==
2016-04-09 07:06:47 SERVER -> CLIENT: 235 Authentication successful
2016-04-09 07:06:47 CLIENT -> SERVER: MAIL FROM:<304906398@qq.com>
2016-04-09 07:06:47 SERVER -> CLIENT: 250 Ok
2016-04-09 07:06:47 CLIENT -> SERVER: RCPT TO:<304906398@qq.com>
2016-04-09 07:06:47 SERVER -> CLIENT: 250 Ok
2016-04-09 07:06:47 CLIENT -> SERVER: DATA
2016-04-09 07:06:47 SERVER -> CLIENT: 354 End data with <CR><LF>.<CR><LF>
2016-04-09 07:06:47 CLIENT -> SERVER: Date: Sat, 9 Apr 2016 07:06:20 +0000
2016-04-09 07:06:47 CLIENT -> SERVER: To: John Doe <304906398@qq.com>
2016-04-09 07:06:47 CLIENT -> SERVER: From: First Last <304906398@qq.com>
2016-04-09 07:06:47 CLIENT -> SERVER: Subject: PHPMailer SMTP test
2016-04-09 07:06:47 CLIENT -> SERVER: Message-ID: <f9010519d87298857d56494c966fcdfb@localhost>
2016-04-09 07:06:47 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.14 (https://github.com/PHPMailer/PHPMailer)
2016-04-09 07:06:47 CLIENT -> SERVER: MIME-Version: 1.0
2016-04-09 07:06:47 CLIENT -> SERVER: Content-Type: multipart/alternative;
2016-04-09 07:06:47 CLIENT -> SERVER: boundary="b1_f9010519d87298857d56494c966fcdfb"
2016-04-09 07:06:47 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: This is a multi-part message in MIME format.
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: --b1_f9010519d87298857d56494c966fcdfb
2016-04-09 07:06:47 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: This is a plain-text message body
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: --b1_f9010519d87298857d56494c966fcdfb
2016-04-09 07:06:47 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2016-04-09 07:06:47 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: 测试邮件
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: --b1_f9010519d87298857d56494c966fcdfb--
2016-04-09 07:06:47 CLIENT -> SERVER:
2016-04-09 07:06:47 CLIENT -> SERVER: .
2016-04-09 07:06:48 SERVER -> CLIENT: 250 Ok: queued as
2016-04-09 07:06:48 CLIENT -> SERVER: QUIT
2016-04-09 07:06:48 SERVER -> CLIENT: 221 Bye
Message sent!
openssl s_client
OpenSSL> s_client -connect smtp.qq.com:465
Loading 'screen' into random state - done
CONNECTED(00000170)
depth=1 C = US, O = GeoTrust Inc., CN = GeoTrust SSL CA - G3
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=CN/ST=Guangdong/L=Shenzhen/O=Shenzhen Tencent Computer Systems Company L
imited/OU=R&D/CN=pop.qq.com
i:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
1 s:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGbzCCBVegAwIBAgIQZlTnxqFc/rVo50RzuVnejDANBgkqhkiG9w0BAQsFADBE
MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMU
R2VvVHJ1c3QgU1NMIENBIC0gRzMwHhcNMTYwMTI3MDAwMDAwWhcNMTYxMDIzMjM1
OTU5WjCBkzELMAkGA1UEBhMCQ04xEjAQBgNVBAgTCUd1YW5nZG9uZzERMA8GA1UE
BxQIU2hlbnpoZW4xOjA4BgNVBAoUMVNoZW56aGVuIFRlbmNlbnQgQ29tcHV0ZXIg
U3lzdGVtcyBDb21wYW55IExpbWl0ZWQxDDAKBgNVBAsUA1ImRDETMBEGA1UEAxQK
cG9wLnFxLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALeSY7Vb
60Cvv7P2O+zhaZnqlz/KFs//DH4It3xmyMPFOPUFopzN1h8n3/4FPqGBtqEEuWBE
/o7soZT30E8bw30Tl07VOcYm/fPKi1pyro3hNEdLi5Wlta9fKxDAvw0U3clSq39R
qihYIDAA3QrDuqI54gULa5IZnqM16A9VBULPfIDaXbdgaAIJ5Ak92nC13YcdQYuv
egL6jOWSKzCRTqeRAg+6dWkfce1+gAOCuCUDgAso2EJ+k9nFe/LAMMGdGbe4KI9H
CwpDCMo+2k2u4SQtXOmuYke7nNmRnpJeL3qZnGWsqT7l3N0mYCc/+3zcMfAcmyuo
H90stoWF/G2T2rcCAwEAAaOCAwswggMHMIIBggYDVR0RBIIBeTCCAXWCCm14Mi5x
cS5jb22CEmltYXAuZXhtYWlsLnFxLmNvbYISdXBsb2Fk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sSDdBd/oUYBh60lREwB
DoAi7x37QIjia4yprFCNs/+bV+bee+2nijeNYibgwLQ+5jZL89jC6BVXxLSTenVw
B2bzQPauNo+DOsB6ubY/i5r9p2E1DHAO9AluN/epJZ1gwZhYlOey71s59341w/ql
ZJImDrWch+Gj1ZgnXWnttgOSafqynPA6VtiFyYGF4zLboxIkNiyuwj+ZzuugV97z
IurYVE9FA7vTlfeJhAkG2gIwsA==
-----END CERTIFICATE-----
subject=/C=CN/ST=Guangdong/L=Shenzhen/O=Shenzhen Tencent Computer Systems Compan
y Limited/OU=R&D/CN=pop.qq.com
issuer=/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
---
No client certificate CA names sent
---
SSL handshake has read 3114 bytes and written 649 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : AES256-SHA256
Session-ID: EC24027DEE5134FD4F3A76AF5BB2E0067F554B5C6D849B79E6553167F889F82E
Session-ID-ctx:
Master-Key: 2CF397C97C005FCC0B868C510938FF8528F1AD2D2CD8B5E506EDCD573012B98E
7365709423600F05E6F67C088600CFAF
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 600 (seconds)
TLS session ticket:
0000 - 41 5f c3 2e 23 c2 4a 93-63 be 20 0d 72 77 da 71 A_..#.J.c. .rw.q
0010 - ef 24 81 ac 1c 6a af 45-18 57 88 62 a8 c1 e1 9e .$...j.E.W.b....
0020 - 81 6c 01 9c e4 a5 8d a5-e7 19 38 4f 4c 02 ac fb .l........8OL...
0030 - 58 1d 07 44 06 2b d1 0e-38 91 2a 8d ec 2c 25 c6 X..D.+..8.*..,%.
0040 - d4 ed 30 f5 ab 86 ec 1d-27 2a 10 57 26 94 38 05 ..0.....'*.W&.8.
0050 - d0 6d 09 c2 15 16 0c 05-f4 26 34 87 29 97 ca bd .m.......&4.)...
0060 - 0d 6f 80 6f e3 0d 86 fd-f2 e0 72 15 b1 dd 17 d7 .o.o......r.....
0070 - d8 77 e8 b0 f5 9e dd bd-cf ac d5 2c a1 95 89 81 .w.........,....
0080 - 0e 1d 9c 48 6a 9b 2d 7d-18 98 31 f4 6b 9b 13 ce ...Hj.-}..1.k...
0090 - 0f 7f 58 01 55 3e bc 6e-97 3b eb f3 67 4e b9 81 ..X.U>.n.;..gN..
Start Time: 1460451601
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
---
220 smtp.qq.com Esmtp QQ Mail Serverl