Move emails with procmail if it matches from sender
as im using different email clients to read/send my mails i want to setup procmail to move my emails to a the folder which is normally done by Thunderbird filter feature.
I know that i can do it by using the following code for procmail in my email users .procmailrc file:
:0:
* ^From:.test@host.name.com
myfolder
But i have a list of about 50 email adresses which i would like to move to that specific "myfolder".
So by using
:0:
* ^From:.first@mail.com
* ^From:.second@mail.com
jimsmail
doesnt help, because procmail interprets them by using the AND operater. So the code above would be true if From is first@... AND second@..., which will never be true.
So how do i use the OR operator.
Actually i have a simple text file where all email adresses are. Would be cool to have a feature where procmail ready in that file and checks if From matches with at least one of the lines in the file, the 开发者_如何学编程moves email to "myfolder".
Something like
:0:
* ^From:file(email.txt)
myfolder
Does anybode if this or something similar is possible. I dont want to add these 3 lines 50 times in my procmailrc file.
Procmail uses regexps, so you can separate addresses with the |
character.
:0:
* ^From:.((first|second|third)@mail.com|(fourth|fifth)@othermail.com)
myfolder
would work. Could get a little messy with fifty all on one line, mind...
I found the solution. With this solution im able to use a simple email text file holding all email addresses in each in one line.
The code in my .procmailrc is as follows:
EMAILFILE=/path/to/my/emailfile
FROM=`formail -xFrom: | sed -e 's/ *(.*)//; s/>.*//; s/.*[:<] *//'`
:0
* ? fgrep -qxis $FROM $EMAILFILE
myfolder
精彩评论