Further improved software
[mail.git] / sendmail.sh
1 #!/bin/bash
2 # This script sends the messages in the maildir using ssh
3 # It stops execution if the connection fails.
4
5 source ~/.mail_config.sh
6 ssh-add -l > /dev/null || ssh-add < /dev/null
7 cd $queuecur
8 for i in $(ls $queuecur);
9 do
10 # if the message is cced to me, copy it directly to my inbox.
11 line=$(grep -m 1 -n -e $ccregexp < $i | cut -d : -f 1)
12 if [ -n "$line" ]
13 then
14 cp $i $inboxcur
15 sed -i"" -e "${line}d" -i $i # and delete the CC header
16 fi
17 # send the message over SSH.
18 echo /usr/lib/sendmail -t | cat - $i | ssh -o ConnectTimeout=10 $server || break
19 rm $i
20 done