summaryrefslogtreecommitdiffstats
path: root/mailto
blob: 029df0ff00e60eb69585ed4c1a4aeb2fa2e09e7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/zsh
# Depends on url-utils package and zenity
mailto="${1%\?*}"
subject="$(urldecode <<<${${${1#*\?}%&*}#*=})"
body="$(urldecode <<<${${${1#*\?}#*&}#*=})"

zenity --question --height 400 --width 680  --text "Send mail with subject $subject ?"

[[ $? -eq 1 ]] && exit

echo -e "\nDate: $(date -R)
Mailto: $mailto
Subject: $subject
Body: $body\n" >>| ~/logs/mailto.log


if [[ ! -z "$body" ]];then
    /usr/bin/mutt -s "$subject" "$mailto" <<<"$body"
else
    urxvt -e /usr/bin/mutt -s "$subject" "$mailto"
fi

if [[ $? eq 1 ]];then
    ~/bin/notify-send "Something went wrong..oops"
else
    ~/bin/notify-send "Mail with $subject successfully sent"
fi