diff --git a/contrib/mdeliver_once.rc b/contrib/mdeliver_once.rc new file mode 100755 index 00000000..d248b8d3 --- /dev/null +++ b/contrib/mdeliver_once.rc @@ -0,0 +1,29 @@ +#!/usr/bin/env rc + +# Deliver a stream of mboxrd emails into a given maildir making sure +# there are no duplicates. +# Duplicates are checked through the Message-ID only. +# This script expects a feed of emails, as in `mdeliver -M` + +if (~ $1 "") { + echo "missing maildir" + exit 1 +} +mmkdir $1 + +tmpdir=`{mktemp -d '/tmp/sfeed_deliver.XXXX'} +fn sigexit { + rm -r $tmpdir +} + +mmkdir $tmpdir/work + +mdeliver -M $tmpdir/work + +mlist $1 | mhdr -h 'Message-ID' > $tmpdir/ids +for (file in `{mlist $tmpdir/work}) { + myid=`{mhdr -h 'Message-ID' $file} + if (! grep -s $myid $tmpdir/ids) { + mdeliver $1 < $file + } +} diff --git a/contrib/mmailto b/contrib/mmailto index 7feabb40..2b38defc 100755 --- a/contrib/mmailto +++ b/contrib/mmailto @@ -19,7 +19,7 @@ fi IFS=' ' -exec $TERMINAL -e mcom $( +args=$( awk -v url="$1" ' function decode(s) { @@ -47,7 +47,7 @@ BEGIN { split(fields[i], kv, "=") if (kv[1] != "r") { args[length(args)+1] = "-" kv[1] - args[length(args)+1] = kv[2] + args[length(args)+1] = "\"" kv[2] "\"" } } for (i in args) { @@ -56,3 +56,5 @@ BEGIN { } ' ) + +exec $TERMINAL -e "mcom $args" diff --git a/man/mcom.1 b/man/mcom.1 index 957c3229..08592c72 100644 --- a/man/mcom.1 +++ b/man/mcom.1 @@ -130,6 +130,13 @@ Delete the draft and quit. Preview the draft, using .Xr mshow 1 . .El +.Sh ATTACHMENTS +From within the editor, attachments are added by setting an Attach: header with the path to the desired files. Multiple Attach: headers can be added. + +To add from the commandline, use +.Sq mcom Fl attach No path/to/file +and the header will be added automatically. +It is possible to use tilde (~) in the file path. .Sh ENVIRONMENT .Bl -tag -width Ds .It Ev EDITOR , Ev VISUAL diff --git a/mcom b/mcom index 4e834c6e..dc9c0635 100755 --- a/mcom +++ b/mcom @@ -287,7 +287,7 @@ fi printf '\n' ( IFS=$NL - cat -- /dev/null $(printf '%s' "$hdrs" | mhdr -M -h body -) + cat -- /dev/null <(printf '%s' "$hdrs" | mhdr -M -h body -) ) printf '\n' ;; @@ -306,6 +306,19 @@ fi msgid museragent cat "$MBLAZE/headers" 2>/dev/null + if [ -n "$raw" ]; then + prev=$(pwd) + attachdir=$(mktemp -d) + cd $attachdir + trap 'rm -r "$attachdir"' EXIT + + mseq -r "$@" \ + | xargs -I {} mshow -Bx {} \ + | xargs -I {} realpath {} \ + | sed '/^$/d; s/^/Attach: /' + cd $prev + fi + printf '\n\n' if [ -z "$raw" ]; then mseq -r "$@" | sed 's:^:#message/rfc822#inline :; s:$:>:' @@ -531,7 +544,7 @@ while :; do c=send ;; d|delete) - rm -i "$draft" + rm "$draft" if ! [ -f "$draft" ]; then rm -f "$draftmime" printf '%s\n' "mcom: deleted draft $draft"