send-mail - postreich - Unnamed repository; edit this file 'description' to name the repository. DIR Log DIR Files DIR Refs DIR README --- send-mail (1063B) --- 1 #!/bin/sh 2 # 3 # Example: send-mail -h roygbyte -t 1 -m ":)" 4 . ./common 5 6 handle="" 7 message="" 8 template="" 9 10 while getopts "h:t:m:" f; do 11 case $f in 12 h) handle="$OPTARG" ;; 13 t) 14 template="$OPTARG" 15 result=$( verify_template "$template" ) 16 if [ $? -eq 1 ]; then 17 printf "$result\n" 18 exit 19 fi 20 ;; 21 m) message=$( sanitize_message "$OPTARG" ) ;; 22 esac 23 done 24 25 # verify message accocrding to type 26 result=$( printf "%s\n" | "$TEMPLATES/$template/main" ) 27 if [ ! $? -eq 0 ]; then 28 printf "$result" 29 return 1 30 fi 31 printf "%s\n" "$result" 32 33 result=$( ./get-mailbox -k "$handle" ) 34 if [ ! $? -eq 0 ]; then 35 printf "$result" 36 return 1 37 fi 38 pubkey="$result" 39 40 result=$( ./get-mailbox "$handle" ) 41 if [ ! $? -eq 0 ]; then 42 printf "$result" 43 return 1 44 fi 45 mailbox="$result" 46 47 result=$( printf "%s" "$message" \ 48 | encrypt_with_key_and_encode "$pubkey" ) 49 if [ ! $? -eq 0 ]; then 50 printf "Encryption or encoding failed.\n" 51 return 1 52 fi 53 54 timestamp=$( date ) 55 printf "%s,%s\n" "$timestamp" "$result" >> "$mailbox" 56 57 58 59