Exim pipe outgoing emails not working

VMunich

Member
May 27, 2015
7
1
3
Boston
cPanel Access Level
DataCenter Provider
Hello,

I would like to pipe all emails Exim sends through a Python script. This script will keep a database of sending behavior, and suspends outgoing email for some domains in case of abuse, using WHM API.

I haven't coded such script yet, as I'm still not able to send emails from Exim through my script.

I have done this in Exim Configuration Manager > Advanced Editor:

Code:
Section: ROUTESTART
outgoing_processor:
  driver    = accept
  condition = ${lookup {$sender_address_domain} \
    lsearch {/etc/localdomains} {yes}}
  transport = outgoing_script
  unseen

Section: TRANSPORTSTART
outgoing_script:
  driver  = pipe
  command =  /usr/bin/tee -a /root/exim_spam_filter/outgoing.log
I'm using tee just to save the pipe output to a file, however it's not working. Emails are being delivered, but the pipe command is not being executed.

Did I miss something?
 
  • Like
Reactions: habpharmacy

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
Hello,

I see a similar custom Exim configuration referenced on the following StackOverflow thread:

Mail Routing using pipe in Exim

Could you let us know if the pipe output works when using the syntax referenced on that thread?

Thank you.
 

CaMer0n

Well-Known Member
Nov 8, 2004
58
0
156
I know this is an old thread, but no where else on the internet could I find a solution.
Here's what I worked out, in case it can help someone else here.

Piping incoming and outgoing mail to a PHP script with Exim.

Add this to the configuration via Exim Configuration Manager. (Advanced Editor)

Section PREROUTERS

support_outgoing_router:
driver = accept
domains = !+local_domains
transport = support_transport
unseen

support_incoming_router:
driver = accept
domains = mydomain.com
transport = support_transport
unseen


Section TRANSPORTSTART

support_transport:
driver = pipe
user = (use FTP to find user of script)
group = (use FTP to find group of script)
debug_print = "T: support_transport_script for [email protected]$domain"
command = /usr/local/bin/php -q /home/account/path-to-my-script.php


(There's probably a way to combine the routers into one entry, but I didn't find a way to do that yet)
The script is just a regular PHP file, make sure it is executable (755) and the shebang (#!.....) is not necessary.