Quick Procmail Question - Accept Only From
am 09.01.2006 04:08:31 von oshidori
Hello all =). To keep this short, I've found lots of great procmail tutorials on the web, but they mostly focus on taking e-mails and putting them somewhere. I am looking for a solution to either A) Accept e-mail from one specific address or B) Send e-mails from every address accept one specific to /dev/null (as you can see they both do the same thing, but I was not able to figure out exactly how to do either. I know it's painfully simple so it pains my geeky heart to post this, but any help would be great =).
Re: Quick Procmail Question - Accept Only From
am 09.01.2006 05:44:51 von Garen Erdoisa
oshidori@gmail.com wrote:
> Hello all =). To keep this short, I've found lots of great procmail tutorials on the web, but they mostly focus on taking e-mails and putting them somewhere. I am looking for a solution to either A) Accept e-mail from one specific address or B) Send e-mails from every address accept one specific to /dev/null (as you can see they both do the same thing, but I was not able to figure out exactly how to do either. I know it's painfully simple so it pains my geeky heart to post this, but any help would be great =).
>
>
There are a couple of ways to do this. Here is one I would suggest.
# Define the locaton of formail on your system
FORMAIL=/usr/bin/formail
# Define a new line character for use in LOG statements.
NL="
"
# Enumerate the Recieved: headers, and store them in the ${RECIEVEDHEAD}
# variable. This also puts the header(s) each on one line,
# and removes multiple tabs and spaces replacing them with
# single spaces. Note the use of backtics to launch a the shell script
# Doing this makes it easier to parse the information in the received
# headers later on.
:0 W
* H ?? 1^1 ^Received:
{
RECEIVEDCOUNT=$=
RECIEVEDHEAD=`${FORMAIL} -cX"Received:" |\
cat -n |\
sed -e 's/\t/ /g' -e 's/[ ]\+/ /g' -e 's/^ //' -e 's/^[0-9]\+/&:/' \
`
}
# Log what you just extracted to your procmail log for debugging.
LOG="[$$]$_: Debug:
RECIEVEDHEAD=${NL}${RECIEVEDHEAD}${NL}RECEIVEDCOUNT=${RECEIV EDCOUNT}${NL}"
# Extract the IP from the 1st recieved header.
# My system uses headers generated by sendmail. You may need
# to adjust the regular expression on your system depending
# on the software you are using.
:0
* RECIEVEDHEAD ?? ^1: Received: from .*\(.*\[\/[0-9.]+
{ IP=${MATCH} }
# Test the ip to see if it's in our whitelist file.
# You'll need to populate your ${HOME}/.whitelistip file with
# the IP's you wish to accept email from.
:0:
* ? grep -Fx "${IP}" ${HOME}/.whitelistip
${DEFAULT}
# It's not whitelisted, so dilver the email to the bit bucket.
:0 E
{
LOG="[$$]$_: ${IP} is not whitelisted. Delivered to /dev/null${NL}"
:0
/dev/null
}
Re: Quick Procmail Question - Accept Only From
am 09.01.2006 05:52:06 von bgates
wrote:
> I've found lots of great procmail tutorials on the web, but they
> mostly focus on taking e-mails and putting them somewhere. I am
> looking for a solution to either A) Accept e-mail from one specific
> address or B) Send e-mails from every address accept one specific
> to /dev/null
One way to do that is to have two procmail recipes: first, a procmail
recipe that tests to see if the email is from the specific address,
and if it is, then moves it to the mailbox of your choice or to
${DEFAULT}; the procmail recipe after that would move all email to
/dev/null. Procmail stops processing if there is a match; if there
is not a match, then the next recipe is tried.
Your NewsBin Pro is not wrapping long lines.