Heim  >  Artikel  >  php教程  >  PHPMailer在SAE上无法发送邮件的解决方法

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

WBOY
WBOYOriginal
2016-05-24 09:00:061309Durchsuche

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 
);

//修改为: 

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

//即可。 

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


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn