blob: 1a6d5ad702437a6af459c7031233f6759d68c702 (
plain) (
blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/bin/sh
# msendmail TO... < msg - compose MIME mail noninteractively
# -F from-name
# -a attach-file
# -b bcc
# -c cc
# -f from
# -s subject
# -m msg-paragraph
IFS='
'
MBLAZE=${MBLAZE:-$HOME/.mblaze}
from=$(mhdr -h local-mailbox "$MBLAZE/profile")
subj=
bcc=
cc=
msg=
fromname=
att=
hdr() {
[ -z "$2" ] && return
printf '%s: ' "$1"
shift
printf '%s\n' "$@" | sed ':a;N;s/\n/, /;$!b a'
}
while getopts a:s:b:c:m:f:F: opt; do
case "$opt" in
s) subj=$OPTARG;;
b) bcc="$bcc$IFS$OPTARG";;
c) cc="$cc$IFS$OPTARG";;
m) msg="$msg$OPTARG$IFS$IFS";;
f) from=$OPTARG;;
F) fromname=$OPTARG;;
a) att="$att$IFS$OPTARG";;
[?]) exit 1;;
esac
done
shift $((OPTIND-1))
[ -n "$from" ] && [ -n "$fromname" ] && from="$fromname <$from>"
{
hdr To "$@"
hdr Cc $cc
hdr Bcc $bcc
hdr Subject $subj
hdr From $from
hdr User-Agent "mblaze/beta (msendmail)"
hdr Message-Id "$(mgenmid)"
hdr Date "$(mdate)"
printf '\n'
if [ -n "$msg" ]; then
printf '%s' "$msg"
else
cat
fi
for a in $att; do
printf '#%s %s\n' "$(file -b --mime-type "$a")" "$a"
done
} | mmime
|