forward emails AFTER local store
Answeredin my current config I have 4 mail-accounts and using 'default address' multiple domains forward all mail to one of this accounts (multiple domains per account)
also I have spam-filters active and several othere rules to recject or multiply emails (some addresses get stored in 2 accounts) in cpanel
so now I updated the software we mainly use to read and manage emails is able to receive mails via SMTP directly while I still need the emails to be stored in cpanel accounts and all filters and rules need to stay alive
my question is how to forward mails AFTER they got stored in specific accounts?
what I tried:
ROUTERSTART
df_forward_sample:
driver = manualroute
domains = example.com
condition = ${if eq{$local_part@$domain}{test@example.com}}
transport = smtp_forward_example
route_list = * 19.14.55.23::25
TRANSPORTSTART
smtp_forward_example:
driver = smtp
port = 25
hosts = 19.14.55.23
emails get forwarded but the get forwarded directly so so the don't get stored and on errors the sender gets some details they shouldn't get (like smtp_forward_example@servername)
and I think also my cpanel-rules seem not to get applied.
do I have a chance to forward as I like to?
thanks :-)
-
Hey there! Is there something in common with all the emails you'd like to do this with so you could use a filter instead of custom Exim changes?
0 -
I don't see an option to forward emails via STMP using filter, can you explain?
0 -
Well, it wouldn't be a typical forward, but you could do something like this to deliver to a folder, in this case being the user's inbox, and then also add a forwarder:
You could even setup additional rules to process these based on subject line or sender or whatever you'd like.
0 -
thanks, just I need to forward it to "the same address on another server"
the mail need's to stay the same and also all adresses so I'll give it a try but I'm quite sure it doesn't fit my needs :-(
/etc/cpanel_exim_system_filter could be a way, but I didn't got it working and I think mails would get forwarded before rules and filter get applied?
also my local mailboxes don't match the receiver-addresses so it seems to hard to save it correctif $h_to: contains "user1@domain1.com" or
$h_to: contains "user2@domain2.com" or
$h_to: contains "@domain3.com" or
$h_to: contains "@domain4.com"
then
save "/home/${local_part}/mail/processed/"
deliver "smtp_forward_example"
seen finish
endif0 -
I don't understand exactly what you're trying to do at this point. Can you get me more specifics on what you're trying to do, and how the option I outlined wouldn't work?
0 -
after some more research and testing may something like this could help me:
just exim seems not to have access to execute sendmail?
I tried a sh-script before to forward the email to the other server without changing anything in the email
without sudo I get 'exim: permission denied; not admin'so I used visudo and added '
exim ALL=(ALL) NOPASSWD: /usr/sbin/sendmail'
using sudo I get this reply:We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required0 -
oh, I have to use the username in visudo
now I don't get an error anymore but also the mail doesn't get forwarded - I don't see any activity on the other server
2024-06-26 02:58:44 SMTP connection from [209.85.218.45]:53745 (TCP/IP connection count = 1)
2024-06-26 02:58:44 H=mail-ej1-f45.google.com [209.85.218.45]:53745 Warning: Sender rate 1.0 / 1h
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf H=mail-ej1-f45.google.com [209.85.218.45]:53745 Warning: "SpamAssassin as xxUser detected message as NOT spam (-96.7)"
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf H=mail-ej1-f45.google.com [209.85.218.45]:53745 Warning: Message has been scanned: no virus or other harmful content was found
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf <= someone@gmail.com H=mail-ej1-f45.google.com [209.85.218.45]:53745 P=esmtps X=TLS1.3:TLS_AES_128_GCM_SHA256:128 CV=no S=5512 id=CALm2QD3pAp...6DkhpOxeO@mail.gmail.com T="another test" for user1@domain1.com
2024-06-26 02:58:45 SMTP connection from mail-ej1-f45.google.com [209.85.218.45]:53745 D=0s closed by QUIT
2024-06-26 02:58:45 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1sMGzk-00000001iFS-2lYf
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf => all_mail ("all_mail"@domain1.com) <user1@domain1.com> R=virtual_user T=dovecot_virtual_delivery C="250 2.0.0 <all_mail@domain1.com> ch5VGsVne2ZvOwYAEqwRdA Saved"
2024-06-26 02:58:45 cwd=/home/xxUser 4 args: /usr/sbin/sendmail -S 14.1.53.26:2504 -i
2024-06-26 02:58:45 Start queue run: pid=408445 -S 14.1.53.26:2504
2024-06-26 02:58:45 End queue run: pid=408445 -S 14.1.53.26:2504
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf => |sudo /usr/sbin/sendmail -S 14.1.53.26:2504 -i ("all_mail"@domain1.com) <user1@domain1.com> R=central_filter T=virtual_address_pipe
2024-06-26 02:58:45 cwd=/home/xxUser 4 args: /usr/sbin/sendmail -S 14.1.53.26:2504 -i
2024-06-26 02:58:45 Start queue run: pid=408452 -S 14.1.53.26:2504
2024-06-26 02:58:45 End queue run: pid=408452 -S 14.1.53.26:2504
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf => |sudo /usr/sbin/sendmail -S 14.1.53.26:2504 -i <user1@domain1.com> R=central_filter T=virtual_address_pipe
2024-06-26 02:58:45 1sMGzk-00000001iFS-2lYf Completed
(using my upper soluting ROUTERSTART+TRANSPORTSTART) I see the mail in the local mail queue until it is delivered which is the prefered behavior0 -
The logs show that it's calling your custom "pipe to a program" script so the issue is somewhere there. What specifically are you trying to do with sendmail that you couldn't just do with the "forward to address" function?
0 -
I now did it similar to your suggstion
so a route was added like this:
ROUTERSTART
df_forward_sample:
driver = manualroute
domains = example.local
transport = smtp_forward_example
route_list = * 19.14.55.23::25
TRANSPORTSTART
smtp_forward_example:
driver = smtp
port = 25
hosts = 19.14.55.23and in 'Default Address' for the domain i added
_inbox@domain1.com,_inbox@example.local
all extra rules in cpanel work and the software on the other server was modified so it deliveres correct
not the way I wanted, but works fine now, thanks :-)0 -
I'm glad you found a good solution for this!
0
Please sign in to leave a comment.
Comments
10 comments