Exim system wide filter file - mail command not working

phil99

Well-Known Member
Jun 10, 2018
59
24
58
UK
cPanel Access Level
Root Administrator
I have written an exim system-wide custom filter file, which is placed in /usr/local/cpanel/etc/exim/sysfilter/options/.

The file freezes some emails based upon a condition, so that they can be reviewed by an administrator. The file is essentially:

Code:
if
  condition
then
  headers add "custom_header"
  mail to "<[email protected]>"
       subject "email subject"
       text "some text"
  freeze text "Frozen by system filter"
endif
The rule works - the header gets added and the emails get frozen. However, the mail command does not work.

At first, exim_mainlog showed the error:

<system-filter> routing defer (-1): system_filter_reply_transport is unset

which lead me to the setting system_filter_reply_transport in exim.conf

I was able to set this from the WHM Exim Advanced Editor interface. However, there is no guidance on what the setting should be. Being as the email would be sent to a user on the system (not externally), I tried:

system_filter_reply_transport = dovecot_virtual_delivery

However, exim_mainlog then showed the error:

system-filter> T=dovecot_virtual_delivery defer (-1): Failed to connect to socket /var/run/dovecot/lmtp for dovecot_virtual_delivery transport: Permission denied

My searching has found very little on the subject. Can anyone help with this?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Hey there! On the cPanel side of things, we don't support this level of custom Exim filtering, so I'm not sure I personally will have any helpful ideas.

Exim does mention setting an errors address instead of using the "mail" command, which is outlined in section 7 here:


so is it possible that would do what you'd like with a built-in function?

I'll also leave this post marked as new for a bit in case any other users have experience in this area.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
It's also worth noting the following (this output was taken from a test machine)

Code:
# grep system_filter_user /etc/exim*
/etc/exim.conf:system_filter_user = cpaneleximfilter
The cpaneleximfilter user doesn't have the ability to send mail directly, so you might do better calling a PHP script or something similar, if my above ideas don't help the situation.
 

phil99

Well-Known Member
Jun 10, 2018
59
24
58
UK
cPanel Access Level
Root Administrator
Thanks @cPRex. I realise you can't support every exim customisation, but I was hoping someone might have already solved this.

We have the default settings for system_filter* in exim.conf:

Code:
system_filter_user = cpaneleximfilter
system_filter_group = cpaneleximfilter
system_filter = /etc/cpanel_exim_system_filter
I'll have a look at the errors address setting as a workaround.
 
  • Like
Reactions: cPRex

phil99

Well-Known Member
Jun 10, 2018
59
24
58
UK
cPanel Access Level
Root Administrator
After some further searching I found a post from 2002 on the exim-users mailing list archive, which give me a clue as to the correct transport to use:

system_filter_reply_transport = address_reply