Home > php教程 > php手册 > body text

PHPMailer在SAE上无法发送邮件的解决方法

WBOY
Release: 2016-05-24 09:00:06
Original
1335 people have browsed it

PHPMailer在SAE上无法发送邮件怎么回事呢,我们以前在php5.2.7版本中使用了PHPMailer是可以发,但移到sae中发现无法发邮件了,那么此问题如何解决.

在SAE上直接用5.2.7之前版本的PHPMailer发送邮件会出现错误,原因在于PHPMailer默认使用stream_socket_client()来建立socket,而SAE禁用了这个函数,WordPress使用的就是5.2.7版本的PHPMailer,因此也会出现同样的问题.

解决方法很简单,修改class.smtp.php(WordPress中是wp-includes/class-smtp.php)中如下代码:

$this->smtp_conn = @stream_socket_client( 
    $host . ":" . $port, 
    $errno, 
    $errstr, 
    $timeout, 
    STREAM_CLIENT_CONNECT, 
    $socket_context 
);
Copy after login

//修改为:

$this->smtp_conn = fsockopen($host, $port, $errno, $errstr);
Copy after login

//即可。 

最新的5.2.8版PHPMailer已经解决了这个问题.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template