added first (incomplete)version of pipe script to get at least one mail sent encrypted and signed

This commit is contained in:
Gulliver 2021-04-26 17:08:43 +02:00
parent 4a6f66af1a
commit 280884a058
3 changed files with 111 additions and 0 deletions

101
mail2members.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/sh
usage()
{
echo "usage"
echo "====="
echo ""
echo "reads a csv-file with member-data and a text-template from template"
echo "uses erb to fill the template with data, encrpyt and sign the mail with the members public pgp key and send it via swaks(swiss army knife for smtp)"
echo ""
echo "./$0"
echo "\t-h --help"
echo "\t--member-data=member-data.csv"
echo "\t--template=template.erb"
echo "\t--subject=subject"
echo "\t--smtphost=smtphost"
echo "\t--smtpuser=smtpuser"
echo "\t--smtppassword=smtppassword"
echo ""
}
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
-n)
DRYRUN=1
;;
--member-data)
MEMBER_DATA=$VALUE
;;
--template)
TEMPLATE=$VALUE
;;
--subject)
SUBJECT=$VALUE
;;
--smtphost)
SMTPHOST=$VALUE
;;
--smtpuser)
SMTPUSER=$VALUE
;;
--smtppassword)
SMTPPASSWORD=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
if [ -z "$MEMBER_DATA" ] ; then
echo "parameter member-data missing"
echo ""
usage
exit
fi
if [ -z "$TEMPLATE" ] ; then
echo "parameter template missing"
echo ""
usage
exit
fi
if [ -z "$SUBJECT" ] ; then
echo "parameter userid missing"
echo ""
exit
fi
echo "MEMBER_DATA = "$MEMBER_DATA
echo "TEMPLATE = "$TEMPLATE
echo "SUBJECT = "$SUBJECT
if [ -z "$DRYRUN" ] ; then
echo "real run"
erb column1=Column1 column2=Column2 column3=Column3 $TEMPLATE\
| gpg2 --batch --yes -vvv -u vorstand@wtf-eg.de \
--no-emit-version -eas -r "42152130EE5C8BED881AB911D65BA8BC7E8B9302" \
| swaks --to frank.landgraf@web.de \
--from "vorstand@wtf-eg.de" \
-tls \
--auth LOGIN \
--server $SMTPHOST \
--auth-user $SMTPUSER \
--auth-password $SMTPPASSWORD \
--header "Subject: $SUBJECT" --body -
else
echo "dry run"
erb column1=Column1 column2=Column2 column3=Column3 $TEMPLATE
erb column1=Column1 column2=Column2 column3=Column3 $TEMPLATE|gpg2 --batch --yes -vvv -u vorstand@wtf-eg.de --no-emit-version -eas -r "42152130EE5C8BED881AB911D65BA8BC7E8B9302"
fi

View File

@ -0,0 +1,3 @@
Line,Nick,Email,PGP,Passwort
110,gulliver,frank.landgraf@web.de,4215 2130 EE5C 8BED 881A B911 D65B A8BC 7E8B 9302,this is not my real password
1 Line Nick Email PGP Passwort
2 110 gulliver frank.landgraf@web.de 4215 2130 EE5C 8BED 881A B911 D65B A8BC 7E8B 9302 this is not my real password

7
test/test.erb Normal file
View File

@ -0,0 +1,7 @@
Sehr geehrtes Mitglied <%= column1 %>,
Loginname: <%= column2 %>
Passwort:<%= column3 %>
Mit freundlichen Grüßen,
Bossman