On 19/12/2020 12:20, Jenny Hopkins wrote:
Hello,
I'm trying to make a global version of the .forward file for exim4, instead of each user having their own. I want this to send messages flagged as spam straight to that users spam box. To do this, I need to extract the user part of the email address. I've found this helpful line:
# echo "john@somewhere.com" | cut -d@ -f1 john
but can't work out how to put it in a format that exim will like.
if $h_to: blah then save /home/$home/Maildir/.spam add 1 to n0 endif
That "blah" need to extract the name from the header and set it as $home. Any hints welcome!
Does this help? https://www.exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_fil...
seems that $local_part is wibble if the email address is wibble@wobble.example
$home seems to be the user's home directory - I'm not sure if this would be /home/wibble, or just wibble.
So perhaps
" if TEST_FOR_SPAM #1 seen save /home/$local_part/mail/Junk #2 finish #3 endif
##deliver normal mail "
Obviously, don't include the #1, #2, #3, they're comments:
#1 - you've got to have some sort of test for the spam - I presume you know what it is?
#2a) Seen Save to mark the mail as read
#2b I'm not sure if this line should would start /home/$local_part or $local_part
depending if $local_part is fully qualified or just the user name.
#2c The end of the line would have to be the name of your mail directory, followed by the spam folder - for me it's mail/Junk. YMMV
#3 finish - If you've dealt with the mail, finish will signal that you don't need to any further processing. Without this it will execute all further tests in the .forward file.
Hope this helps.
Obviously you'll need to do a bit more testing to see what works. Let us know!
Steve