PHPMailer and function escapeshellcmd()

痴心易碎 提交于 2019-12-02 05:14:34

No, escapeshellcmd() has some inherent problems which make it worth disabling for many, but you can work around it a different way: use SMTP to localhost instead.

By default PHPMailer uses the PHP mail() function for sending, which calls a local sendmail binary via a shell (requiring the use of escapeshellcmd()), which in turn opens a synchronous SMTP connection to your mail server on localhost. You can skip much of this by sending directly to localhost yourself, bypassing the shell overhead. Do this:

$mail->isSMTP();
$mail->Host = 'localhost';

Other settings should work with defaults. Two advantages of using SMTP to localhost are that you can get much better feedback on the submission process (with $mail->SMTPDebug = 2;), and it's also faster than using mail().

You can use an older version. I used Version: 5.2.6 and it works.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!