PHPMailer和函数escapeshellcmd() [英] PHPMailer and function escapeshellcmd()
问题描述
我使用新版本的PHPMailer.在服务器上,出现错误:
I use new version of PHPMailer. On the server, I get an error:
警告:出于安全原因,在第1442行的/public_html/library/email/class.phpmailer.php中已禁用escapeshellcmd()
Warning: escapeshellcmd() has been disabled for security reasons in /public_html/library/email/class.phpmailer.php on line 1442
有没有可以代替escapeshellcmd()
的功能?
Is there a function that could replace escapeshellcmd()
?
推荐答案
不, escapeshellcmd()
有一些固有的问题,这使许多人都不得不禁用它,但是您可以采用另一种方法来解决它:使用SMTP代替本地主机.
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.
默认情况下,PHPMailer使用PHP mail()
函数进行发送,该函数通过外壳程序调用本地sendmail二进制文件(要求使用escapeshellcmd()
),该程序壳反过来在本地主机上打开到您的邮件服务器的同步SMTP连接.您可以通过直接发送给本地主机来跳过很多操作,而无需考虑shell开销.这样做:
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';
其他设置应使用默认设置.使用SMTP到localhost的两个优点是,您可以(使用$mail->SMTPDebug = 2;
)获得有关提交过程的更好反馈,并且比使用mail()
更快.
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()
.
这篇关于PHPMailer和函数escapeshellcmd()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!