filter – Move emails with procmail if it matches from sender – Education Career Blog

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:[email protected]
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:[email protected]
* ^From:[email protected]
jimsmail

doesnt help, because procmail interprets them by using the AND operater. So the code above would be true if From is [email protected]… AND [email protected]…, 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

Leave a Comment