here we go

This commit is contained in:
2014-05-03 16:28:00 +02:00
parent b1f2e01079
commit 57e5470f1b
2 changed files with 117 additions and 0 deletions

29
muttrc Normal file
View File

@@ -0,0 +1,29 @@
# Generated by the muttrc builder (http://muttrcbuilder.org/)
# for mutt-1.5.21
set from = 'kunden@maketank.net' # default: '(empty)'
set realname="Buchhaltung: it.maketank.net"
set use_envelope_from=yes
set imap_authenticators = 'login' # default: '(empty)'
set imap_login = 'kunden@maketank.net' # default: '(empty)'
set imap_pass = 'de3hujmn' # default: '(empty)'
set imap_user = 'kunden@maketank.net' # default: '(empty)'
#set smtp_authenticators = 'login'
#set smtp_pass= 'de3hujmn'
#set smtp_url = "smtp://kunden@maketank.net@smtp.maketank.net:465" # using port 587 for TLS
set sendmail="/usr/bin/esmtp"
set pgp_sort_keys = 'address' # default: 'address'
set pgp_use_gpg_agent = yes # default: no
set signature = '~/.signature-maketank' # default: '~/.signature'
set folder="imaps://imap.maketank.net:993/"
set spoolfile="+INBOX"
set postponed="+Drafts"
set record="+Rechnungen-Raus"
#GNUPG
set pgp_use_gpg_agent = yes
set pgp_sign_as = 20B3D551
set pgp_timeout = 3600
set crypt_autosign = yes
set crypt_replyencrypt = yes

88
verschicke-rechnung.sh Executable file
View File

@@ -0,0 +1,88 @@
#/bin/bash
MYDIR=$(dirname $0)
MUTTRC="${MYDIR}/muttrc"
SRCDIR=$1
FROM="kunden@maketank.net"
TMP=/tmp
send_mail () {
INF=$(pdfinfo $TMP/$FILE 2>&1)
ISA=$(echo "${INF}"|awk '/Title:/ {print $2}')
if [ "${ISA}" == "Mahnung" ]; then
MAHNNUM=$(echo $FILE |sed -e 's/Mahnung-\(.\)-.*pdf/\1/')
SUBJPREFIX="${MAHNNUM}. ${ISA}"
else
MAHNNUM=""
SUBJPREFIX="${ISA}"
fi
META=$(echo "${INF}"|awk -F ' ' '/Keywords:/ {print $3}')
NAME=$(echo "${META}"|sed -e 's;.*<Name:\(.*\)><Zusatz.*$;\1;')
ZUSATZ=$(echo "${META}"|sed -e 's;.*<Zusatz:\(.*\)><Stra.*$;\1;')
NUMMER=$(echo "${META}"|sed -e 's;.*<Nummer:\(.*\)><Erstellt.*$;\1;')
ERSTELLT=$(echo "${META}"|sed -e 's;.*<Erstellt:\(.*\)><Name.*$;\1;')
BETRAG=$(cat ${TMP}/${FILE}.txt |grep Eur|tail -1)
KUNDE=$(cat ${TMP}/${FILE}.txt |awk '/Kunde:/ {print $2}')
TO=$(echo "${META}"|sed -e 's;.*<Mail:\(.*\)><WWW.*$;\1;')
## Build the mail now
SUBJECT="[it.maketank.net] ${SUBJPREFIX} ${NUMMER}"
M=$TMP/$FILE.mailbody
echo "Hallo ${NAME}," >$M
echo "" >>$M
echo "anbei eine aktuelle ${SUBJPREFIX}." >>$M
echo "" >>$M
echo "Rechnungsinformationen:" >>$M
echo "" >>$M
echo " Datum: ${ERSTELLT}" >>$M
echo " Nummer: ${NUMMER}" >>$M
echo " Kunde: ${KUNDE}" >>$M
echo " Betrag: ${BETRAG}" >>$M
echo "" >>$M
echo "" >>$M
echo "Bitte ueberweisen Sie den Ausstehenden Betrag sobald">>$M
echo "wie moeglich unter Angabe ihrer Kundennummer auf folgendes Konto." >>$M
echo "" >>$M
echo " Bank: Deutsche Kreditbank AG" >>$M
echo " IBAN: DE55 12030000 1010825667" >>$M
echo " BIC: BYLADEM1001" >>$M
echo "" >>$M
echo "" >>$M
echo "Vielen Dank und herzliche Gruesze," >>$M
#TO='snurfl@zoide.net'
#echo "==> Sending Mail to: ${TO} "
#echo " Subject: ${SUBJECT}"
#cat $M
#echo -n "Should this be sent [y]/n? "
#read -n 1 REPL
#if [ "${REPL}" == "n" ]; then
# echo " Not sending Mail."
#else
mutt -F "${MUTTRC}" -s "${SUBJECT}" -a $TMP/$FILE -i ${M} -- ${TO}
#fi
#unset REPL
}
archive () {
Y=$(date +%Y)
[[ -d ${SRCDIR}/${Y} ]] || mkdir -p ${SRCDIR}/${y}
mv ${SRCDIR}/${FILE} ${SRCDIR}/${Y}
rm -v /tmp/${FILE}*
}
for PDF in $(ls ${SRCDIR}/*.pdf); do
export FILE=$(basename $PDF)
echo -n "Processing: ${FILE}"
cp $PDF $TMP/
echo -n " [JPEG"
pdfimages -j $TMP/$FILE $TMP/$FILE
echo -n ",OCR"
cuneiform -f smarttext -l ger -o $TMP/$FILE.txt $TMP/$FILE-000.jpg >/dev/null
echo ",MAIL]"
send_mail
archive
unset FILE
done