今天在本機測試好的phpmailer郵箱發送功能沒有問題,本地是windows apache php環境但在了linux中發送郵件就出現了Msg:stream_socket_enable_crypto(): this stream does not support SSL/crypto錯誤了,后來我分析了N久得出一辦法,下面分享給各位朋友。
我的PHPMailer發送郵件代碼
在使用PHPMailer發送郵件報錯Msg:stream_socket_enable_crypto(): this stream does not support SSL/crypto,出現這種情況請輸出phpinfo()看下openssl這個擴展沒有安裝,查找php安裝時源碼包的位置以/usr/local/src/php/php-5.3為例子,代碼如下:
cd /usr/local/src/php/php-5.3/ext/openssl
/usr/local/php/bin/phpize
可能會出現下面的錯誤,代碼如下:
Cannot find config.m4.
Make sure that you run ‘/usr/local/php/bin/phpize’ in the top level source directory of the module
解決辦法,代碼如下:
mv config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
make && make install安裝成功后會有以下提示
Build complete.
Don’t forget to run ‘make test’.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ 改目錄下回生成一個openssl.so文件,找到php的配置文件,在擴展區域添加如下代碼:
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/openssl.so
ps -ef | grep php-fpm | grep -v grep | awk '{print $2}'|xargs kill -9
/usr/local/php/sbin/php-fpm
如果你配置了還不能發送郵箱我們可以嘗試在linux中直接使用mail函數直接發送郵件哦.