PHPMailer and function escapeshellcmd()

▼魔方 西西 提交于 2019-12-20 05:15:52

问题


I use new version of PHPMailer. On the server, I get an error:

Warning: escapeshellcmd() has been disabled for security reasons in /public_html/library/email/class.phpmailer.php on line 1442

Is there a function that could replace escapeshellcmd() ?


回答1:


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().




回答2:


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



来源:https://stackoverflow.com/questions/41846441/phpmailer-and-function-escapeshellcmd

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