Linux – Monitoring sendmail function (php) usage

Often we can encounter server that started to send spam (infected page, virus inside php file, bad plugin).

If its our own server we can very easily monitor usage of sendmail which is commonly used in php to send mails, and we will do it with usage of simply ‘wrapper’ .

 

1. Create /usr/local/bin/phpsendmail:

Lets check where is sendmail:

If its not in this localization /usr/sbin/sendmail then we will need to edit above script

Setup right permissions for file:

2.  Next we need edit php.ini file

If we use PHP as CGI or suPHP, you need edit also /etc/php5/cgi/php.ini

Restart service:

3. Lets test our wrapper

Create mailtest.php in www directory ex. /var/www/example.com/public_html

Open file in browser

Check if you have something in log file:

 

Facebooktwittergoogle_plusreddit

Leave a Reply

Your email address will not be published. Required fields are marked *

*