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!
Thanks, Jenny
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
On Sat, 19 Dec 2020 at 23:14, steve-ALUG@hst.me.uk wrote:
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
Very helpful! Thanks. And how delightful to have wibble as the answer.But simply putting "$local_part in place of $home is blank. I've tried various things like curly braces, and extract, but still struggling to find how to tell exim I want $home to be the user name from the email. I'm coming at it from a bash point of view and trying to imagine setting a variable.
$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
#1 - you've got to have some sort of test for the spam - I presume you know what it is?
At the moment I'm filtering on the X-Spam_bar containing 5 + signs, ideally will find out how to tell rspamd to mark spam by changing the header.
#2a) Seen Save to mark the mail as read
Brilliant.
#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!
Thanks, Jenny