Search code examples
phpexecutewhmexim

Exim & WHM - Run PHP Script on mail rejection


I wrote a script to reject emails if they have zip attachments containing exe, js files..etc etc.. It worked successfully. I wrote the following script under acl_smtp_mime at WHM Exim Advanced Editor:

deny message = "This message might contain harmful files."
condition = ${if match{$mime_filename}{\N(?i)\.zip$\N}}
decode = default
condition = ${if match{${run{/usr/bin/unzip -l $mime_decoded_filename}}} {\N(?i)\.(com|js|pif|scr|lnk|exe)\n\N} }

I am trying to execute a PHP script that inserts a log entry in the databse regarding the rejected email but I failed.

I tried inserting this line at the end but it failed to run the script

continue = ${run{/usr/bin/php '/home/*hidden*/public_html/test.php $mime_decoded_filename'}{0}{1}}

When I run the PHP from the browser just for testing, it runs fine and creates a fake log. It seems I'm not calling the script correctly from EXIM. Emails are rejected successfully but the PHP file is not getting called

Please help. Thank you


Solution

  • I was able to run my php script using curl:

    continue = ${run{/usr/bin/curl http://www.*****.com/test.php?fn=$mime_filename&sa=$sender_address&rf=$recipients}}