一个特定的脚本以apache用户身份运行并执行sendmail。 需要find脚本path

在服务器中似乎有一些脚本正在作为apache用户执行并发送邮件。 看着ps aux的输出,我们发现sendmail可执行文件是用apache用户执行的,但是我们无法find正在执行的特定脚本。

处理这种情况的理想方式是什么?

我想你正在寻找php.ini(仅适用于php 5.3+)的mail.log设置,它将logging所有的mail()函数调用,包括启动调用的脚本:

 ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ;mail.log = ; Log mail to syslog; ;mail.log = syslog 

如果您在服务器上运行PHP,则可以使用以下语法来追踪原始电子邮件脚本。 在php.ini中放置下面的行

 mail.add_x_header = On mail.log = /var/log/phpmail.log 

上面的指令将添加标题与原始的PHP脚本,如下所示

 X-PHP-Originating-Script: 456:mail.php 

以及写入文件/var/log/phpmail.log

 mail() on [/var/www/html/project/tmp/mail.php:456]: To: [email protected] -- Headers: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: 8Bit X-Mailer: Sender: [email protected] From: [email protected]