procmail
[Top] [All Lists]

RE: Filter and Resend Message

2007-05-02 20:14:56

 
Hi,

Six months ago, I started to implement the same idea, a global catch-all
using procmail, and thanks to the help of the user group, I managed get
it implemented with some restrictions. There are very good business
reasons for such implementation, and in my case, I did not know any
better than Procmail, so I used it anyway. The solution, from the
technical point of view, maybe clumsy but it does what I need anyway, In
business, we can not afford to look for perfect solution.

Here is my solution and hope it will help.

# This section was help from Sean:
# get the From: address as an address component ONLY (no comments)
:0 h
CLEANFROM=|formail -IReply-To: -rtzxTo:

# get the To:
:0
* ^(To|Cc):[         ]*\/[^  ].*
{
         TO=$MATCH
}

# this should strip standard comments, and address bracketing,
# then put each result on a separate line (the TR is for that)

MY_TO=`echo ${TO}| sed -e "s/\"[^\"]*\"//" \
         -e "s/\(<\([^>]*\)>\)/\2/g" -e "s/^[    ,]*//" \
         | tr -s "       ," "\n"`

# I add this line to make sure that the  To line may have several
addresses but only yank out the one for our domain
#  in this case penit.com.

MY_TO=`echo ${MY_TO} | gawk '{i=1; while ( i <= NF) {if
(index($i,"penit.com")!=0) print $i; i=i+1;} }'`

# MY_TO could have felix(_at_)penit(_dot_)com view(_at_)penit(_dot_)com for 
example, after set
each to a different name
#  the MY_TO will set to the first name. We only use lower case in Linux
login name.

MY_NAME=`echo ${MY_TO}| gawk -F '@' '{print $1}'|tr 'A-Z' 'a-z'`
MY_TO1=`echo ${MY_TO}| gawk '{print $2}'`
MY_NAME1=`echo ${MY_TO1}| gawk -F '@' '{print $1}'|tr 'A-Z' 'a-z'`
MY_TO2=`echo ${MY_TO}| gawk '{print $3}'`
MY_NAME2=`echo ${MY_TO2}| gawk -F '@' '{print $1}'|tr 'A-Z' 'a-z'`
MY_TO3=`echo ${MY_TO}| gawk '{print $4}'`
MY_NAME3=`echo ${MY_TO3}| gawk -F '@' '{print $1}'|tr 'A-Z' 'a-z'`
MY_TO=`echo ${MY_TO} | awk '{print $1}'`

# Then I make sure the recipient is one of our guys named in a file
called legal_to
:0
* ! MY_TO ?? ^^^^
{
         TO_MATCHED=`grep -iF ${MY_NAME} ${CONFIG}/legal_to`
}
:0
* ! MY_TO1 ?? ^^^^
{
         TO_MATCHED1=`grep -iF ${MY_NAME1} ${CONFIG}/legal_to`
}

:0
* ! MY_TO2 ?? ^^^^
{
         TO_MATCHED2=`grep -iF ${MY_NAME2} ${CONFIG}/legal_to`
}

:0
* ! MY_TO3 ?? ^^^^
{
         TO_MATCHED3=`grep -iF ${MY_NAME3} ${CONFIG}/legal_to`
}


#  Then I check the sender is one of the person we know of named in a
file legal_from.
:0
* ! CLEANFROM ?? ^^^^
{
         FROM_MATCHED=`grep -i ${CLEANFROM} ${CONFIG}/legal_from`
}

# If the sender is known, then we deliver the mail to the recipient
:0
* ! FROM_MATCHED ?? ^^^^
{ 
         :0 c
         * ! MY_NAME ?? ^^^^
         ${INBOX_PATH}/${MY_NAME}
    
         :0 c
         * ! MY_NAME1 ?? ^^^^
         ${INBOX_PATH}/${MY_NAME1}

         :0 c
         * ! MY_NAME2 ?? ^^^^
         ${INBOX_PATH}/${MY_NAME2}

         :0 c
         * ! MY_NAME3 ?? ^^^^
         ${INBOX_PATH}/${MY_NAME3}
}

:0
Treat_as_junk

You need to do the same for CC and the limit is that the To line can
only have 4 recipients of your company.
I ask the staff to put max. 4 names in To line and 4 in CC line and make
a max. of 8 recipients which sufficient for my purposes.
 
I hope this will save you some work and maybe some clever techie out
there can suggest some better solution.

Rgds,
Kfl. HK.
     



On 1-May-2007, at 09:20, Feris Thia wrote:

Hi All,

I have a global (catch-all) account at my ISP.

Stop right there.

Procmail is not an MTA.  It will never be an MTA.  Down this path
lies only madness and The Dark Side.

 
However, this WILL cause problems you WILL lose mail it WILL be a  
constant thorn in your side and you WILL get inundated with spam.

Catch-all addresses are a horrible hideous bad evil idea and should  
be avoided at all costs.
 


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>