简体   繁体   中英

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

I don't think exim knows how to execute .php scripts. You could try to port that php script to perl. Exim on a cPanel/WHM server, by default, has the ability to run perl scripts. You might want to read exim documentation though regarding the php scripts...

我能够使用curl运行我的php脚本:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM