1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 08:12:48 +01:00
imapsync/W/paypal_reply/paypal_send_invoices

55 lines
1.8 KiB
Plaintext
Raw Normal View History

2011-07-11 23:24:12 +02:00
#!/bin/sh
2012-09-03 02:08:57 +02:00
# $Id: paypal_send_invoices,v 1.8 2012/08/24 14:36:18 gilles Exp gilles $
2011-07-11 23:24:12 +02:00
# usages:
# sh paypal_send_invoices /g/var/paypal_invoices/147
# sh paypal_send_invoices /g/var/paypal_invoices/15?
send_invoice() {
test X"" = X"$1" && { echo "usage: send_invoice /g/var/paypal_invoices/147 vince@norestech.net"; return; }
d="$1"
echo "====== $d ======"
#echo
cd $d || return
bd=`basename $d`
#echo "$bd"
invoice="$bd"
if test -f WAIT_DONT_SEND; then
echo "found WAIT_DONT_SEND in $d then exit"
continue
fi
test -f facture_imapsync-${invoice}.pdf || { echo NO facture_imapsync-${invoice}.pdf ; return; }
test -f facture_imapsync-${invoice}.pdf.asc || { echo NO facture_imapsync-${invoice}.pdf.asc ; return; }
test -f facture_message_header.txt || { echo NO facture_message_header.txt ; return; }
test -f facture_message_body.txt || { echo NO facture_message_body.txt ; return; }
test -f email_address.txt || { echo NO email_address.txt ; return; }
2012-09-03 02:08:57 +02:00
email=${2:-`cat email_address_2.txt 2>/dev/null || cat email_address.txt`}
2011-07-11 23:24:12 +02:00
> facture_message_to.txt
egrep '^To: ' facture_message_header.txt > /dev/null || echo "To: $email" > facture_message_to.txt
cat facture_message_header.txt facture_message_to.txt facture_message_body.txt > facture_message.txt
test -f "SENT_TO_$email" && {
echo "!!! Already SENT_TO_$email"
2012-09-03 02:08:57 +02:00
return
2011-07-11 23:24:12 +02:00
}
2012-09-03 02:08:57 +02:00
more facture_message.txt
echo '====== END of message ======'
2011-07-11 23:24:12 +02:00
mailq
test -f "SENT_TO_$email" || acroread facture_imapsync-${invoice}.pdf&
echo "Send this invoice ${invoice} to $email?"
read r < /dev/tty
echo SAID "[$r]"
test X"$r" = Xy && {
echo | mutt -H facture_message.txt -a facture_imapsync-${invoice}.pdf facture_imapsync-${invoice}.pdf.asc --
touch SENT_TO_$email
}
}
2011-09-25 22:31:48 +02:00
echo $0 '/g/var/paypal_invoices/99?'
2011-07-11 23:24:12 +02:00
for d in "$@"; do
( send_invoice "$d" )
done