haiku/docs/user/mail/Mass Mailing Tips/ValidatePeopleEmails.sh
Alexander G.M. Smith c181c43dc1 More documentation moved over from SourceForge, so it's not quite up to date.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15965 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-15 22:43:21 +00:00

30 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# ValidatePeopleEmails
# Goes through all your People files and checks that the e-mail addresses
# are valid. Useful for bulk e-mailing where one bad address will make
# the SMTP mail server reject the whole lot.
# By mmu_man, September 18 2003, inspired by Dane's request, used with
# permission in MDR.
query -a 'META:email==*' | xargs catattr META:email >/tmp/PeopleListTemp
cat /tmp/PeopleListTemp | while read LINE; do
NULLATTR="${LINE#* : string :}"
if [ "x$NULLATTR" = "x" ]; then
echo "WARNING: no email address in $LINE"
continue
fi
PPLFILE="${LINE% : string : *}"
PPL="${PPLFILE##*/}"
THEMAIL="${LINE##* : string : }"
FILTERED="$(echo "$THEMAIL" | sed 's/[A-Za-z0-9.+_-]*\@[A-Za-z0-9._-]*/GOOD/' )"
echo "[$PPL] [$THEMAIL] $FILTERED"
if [ "x$FILTERED" != "xGOOD" ]; then
echo "WARNING: strange email for '$PPL': <$THEMAIL>"
fi
done
sed 's/ $/<--Blanks at the end of the e-mail, BAD!/' </tmp/PeopleListTemp >/tmp/PeopleListOut
sed 's/: string :<--Blanks at the end/No e-mail/' </tmp/PeopleListOut >/tmp/PeopleListBlanked
grep "Blanks at the end" /tmp/PeopleListBlanked