"mail" compatible script that invokes xdg-email

raw

README.rst

The command line "cddb-tool" uses mail to send out CDDB database update mails - but I had no mail installed, only Thunderbird.

xdg-email can be used to invoke all sorts of GUI email clients from command line on Linux, but there was no converter from "mail" to "xdg-email".

This script is it.

raw

mail.sh

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
#!/bin/sh
recipients=""
subject=""
text=$(cat /dev/stdin)
 
mode=""
for i in "$@"; do
    if [ "$i" = "-s" ]; then
        mode=subject
        continue
    else
        if [ "$mode" = "subject" ]; then
            subject=$i
            mode=""
        else
            recipients="$recipients $i"
        fi
    fi
done
 
#echo $recipients
#echo $subject
#echo $text
 
xdg-email --subject "$subject" --body "$text" $recipients
 
Christian Weiske Christian Weiske
owner

History