PHP does not support SMTP verification by default, but Zend does not support this function and does not use the smtp configuration in php. ini. I wrote a reference manual.
PHP does not support SMTP verification by default, but Zend does not support this function and does not use the smtp configuration in php. ini.
I wrote a Test against the Manual. the code is as follows:
Require_once 'zend/Mail. php ';
Require_once 'zend/Mail/Transport/Smtp. php ';
$ Mail = new Zend_Mail ("UTF-8"); // Set the email encoding
$ Config = array ('auth' => 'login ',
'Username' => "tysina.tian@php8848.com", // Electronic parts user name
'Password' => "********",
'SSL '=> "ssl"
);
$ Transport = new Zend_Mail_Transport_Smtp ('smtp .ym.163.com ', $ config );
$ Mail-> setDefaultTransport ($ transport );
$ Mailcontent = 'Welcome!
Your registration name is '. $ config ['username']
.'
Your password is '. $ config ['password']
.'
Click here to activate your account!
Please delete this email as soon as possible to prevent others from stealing your password.
If you forget the password, you can write to the community and ask the administrator to reset it.
';
$ Mail-> setBodyHtml ($ mailcontent );
$ Mail-> setFrom ('tysina. tian@php8848.com ', 'tysina ');
$ Mail-> addTo ('tysina. tian@php8848.com ', 'tysina ');
$ Title = $ config ['username']. ', Hello, this is the website activation verification email! ';
$ Mail-> setSubject ("=? UTF-8? B ?" . Base64_encode ($ title). "? = ");
// $ Mail-> send ();
If ($ mail-> send ()){
Echo "Sent !";
} Else {
Echo "Not sent !";
}
?>
Run, error reported.
The error message is as follows:
(! ) Fatal error: Uncaught exception 'zend _ Mail_Protocol_Exception 'with message 'could not open socket' in C: Program FilesZendFrameworkClilibraryZendMailProtocolAbstract. php on line 277
(! ) Zend_Mail_Protocol_Exception: cocould not open socket in C: Program FilesZendFrameworkClilibraryZendMailProtocolAbstract. php on line 277
Call Stack
# Time Memory Function Location
1 0.0023 72976 {main} () .. 19-0.php: 0
2 0.1056 1137304 Zend_Mail-> send (??? ) .. 19-0.php: 23
3 0.1059 1138528 Zend_Mail_Transport_Abstract-> send (object (Zend_Mail) [1]) .. Mail. php: 1194
4 0.1072 1168240 Zend_Mail_Transport_Smtp-> _ sendMail () .. Abstract. php: 348
5 0.1312 1281048 Zend_Mail_Protocol_Smtp-> connect () .. Smtp. php: 199
6 0.1312 1281048 Zend_Mail_Protocol_Abstract-> _ connect (string (25) .. Smtp. php: 167
View the ZendMailProtocolAbstract. php code and find 265 ~ The code for Line 1 is as follows:
$ ErrorNum = 0;
$ ErrorStr = ";
// Open connection
$ This-> _ socket = @ stream_socket_client ($ remote, $ errorNum, $ errorStr, self: TIMEOUT_CONNECTION );
If ($ this-> _ socket === false ){
If ($ errorNum = 0 ){
$ ErrorStr = 'could not open socket ';
}
/**
* @ See Zend_Mail_Protocol_Exception
*/
Require_once 'zend/Mail/Protocol/Exception. php ';
Throw new Zend_Mail_Protocol_Exception ($ errorStr );
}
That is, @ stream_socket_client ($ remote, $ errorNum, $ errorStr, self: TIMEOUT_CONNECTION) returns false.
The reason is that the default openssl is disabled when appserv is installed, and it will not be created successfully.
The solution is simple. in the php. ini file, find
; Extension = php_openssl.dll
Remove the semicolon, save it, restart apache, and then pass.