mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit d2d687478d055fa0acf2a6452cac324cc6bb54fb
parent d453a5ac58e7e197e22a73ab9fc7ed24c213e383
Author: Christian Neukirchen <chneukirchen@gmail.com>
Date:   Mon,  8 Aug 2016 16:01:06 +0200

rename mcomp -> mcom, mrepl -> mrep

mcomp is in mtools already.

mfwd will be added in the future.

Diffstat:
Makefile | 4++--
README | 4++--
man/mblaze.7 | 4++--
man/mcom.1 | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
man/mcomp.1 | 77-----------------------------------------------------------------------------
man/mrep.1 | 1+
mcom | 167+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mcomp | 167-------------------------------------------------------------------------------
mrep | 2++
mrepl | 2--
10 files changed, 253 insertions(+), 252 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,7 +6,7 @@ BINDIR=$(PREFIX)/bin MANDIR=$(PREFIX)/share/man ALL = maddr magrep mdate mdeliver mdirs mflag mgenmid mhdr minc mlist mmime mpick mscan msed mseq mshow msort mthread -SCRIPT = mcolor mcomp mless mquote +SCRIPT = mcolor mcom mless mquote all: $(ALL) @@ -40,7 +40,7 @@ install: FRC all install -m0755 $(ALL) $(SCRIPT) $(DESTDIR)$(BINDIR) ln -sf mless $(DESTDIR)$(BINDIR)/mnext ln -sf mless $(DESTDIR)$(BINDIR)/mprev - ln -sf mrepl $(DESTDIR)$(BINDIR)/mcomp + ln -sf mrep $(DESTDIR)$(BINDIR)/mcom install -m0644 man/*.[0-9] $(DESTDIR)$(MANDIR)/man1 FRC: diff --git a/README b/README @@ -13,7 +13,7 @@ DESCRIPTION mblaze consists of a set of Unix tools that each do one job: maddr(1) to extract addresses from mail magrep(1) to find mails matching a pattern - mcomp(1) to write and send mail + mcom(1) to write and send mail mdeliver(1) to deliver messages or import mailboxes mdirs(1) to find Maildirs mflag(1) to change flags (marks) of mail @@ -24,7 +24,7 @@ DESCRIPTION mlist(1) to list and filter mail messages mmime(1) to create MIME messages mpick(1) to filter mail - mrepl(1) to reply to mail + mrep(1) to reply to mail mscan(1) to generate single line summaries of mail msed(1) to manipulate mail headers mseq(1) to manipulate mail sequences diff --git a/man/mblaze.7 b/man/mblaze.7 @@ -20,7 +20,7 @@ consists of a set of Unix tools that each do one job: to extract addresses from mail .It Xr magrep 1 to find mails matching a pattern -.It Xr mcomp 1 +.It Xr mcom 1 to write and send mail .It Xr mdeliver 1 to deliver messages or import mailboxes @@ -43,7 +43,7 @@ to list and filter mail messages to create MIME messages .It Xr mpick 1 to filter mail -.It Xr mrepl 1 +.It Xr mrep 1 to reply to mail .It Xr mscan 1 to generate single line summaries of mail diff --git a/man/mcom.1 b/man/mcom.1 @@ -0,0 +1,77 @@ +.Dd July 22, 2016 +.Dt MCOM 1 +.Os +.Sh NAME +.Nm mcom , +.Nm mrep +.Nd compose new, reply to, and send mail +.Sh SYNOPSIS +.Nm mcom +.Op Ar recipient +.Nm mrep +.Ar msg +.Sh DESCRIPTION +.Nm mcom +creates a new draft mail and runs an editor. +After editing, a loop is started where the user can re-edit, send or +cancel the mail. +.Pp +.Nm mrep +behaves like +.Nm mcom +but fills the draft such that the mail will be a reply to the message +.Ar msg . +See +.Xr mmsg 7 +for the message argument syntax. +.Sh MENU COMMANDS +.Bl -tag -width 2n +.It Ic s +Send the mail. +The MIME version will be used when one has been created. +.It Ic c +Cancel sending and quit +.Nm +after displaying the file name of the draft. +.It Ic m +Run +.Xr mmime 1 +on the draft, and show the result of +.Ic mshow -t . +.It Ic e +Re-run the editor on the draft. +.El +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev EDITOR +Editor used to compose mail. +.El +.Sh FILES +.Bl -tag -width Ds +.It Pa snd.* +Draft messages (kept in current directory) +.It Pa ~/.mblaze/headers +Default headers for each mail. +(Put your +.Sq Li From\&: +line there.) +.It Pa ~/.signature +Default signature. +.El +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr mmime 1 , +.Xr mmsg 7 +.Sh AUTHORS +.An Christian Neukirchen Aq Mt chneukirchen@gmail.com +.Sh LICENSE +.Nm +is in the public domain. +.Pp +To the extent possible under law, +the creator of this work +has waived all copyright and related or +neighboring rights to this work. +.Pp +.Lk http://creativecommons.org/publicdomain/zero/1.0/ diff --git a/man/mcomp.1 b/man/mcomp.1 @@ -1,77 +0,0 @@ -.Dd July 22, 2016 -.Dt MCOMP 1 -.Os -.Sh NAME -.Nm mcomp , -.Nm mrepl -.Nd compose new, reply to, and send mail -.Sh SYNOPSIS -.Nm mcomp -.Op Ar recipient -.Nm mrepl -.Ar msg -.Sh DESCRIPTION -.Nm mcomp -creates a new draft mail and runs an editor. -After editing, a loop is started where the user can re-edit, send or -cancel the mail. -.Pp -.Nm mrepl -behaves like -.Nm mcomp -but fills the draft such that the mail will be a reply to the message -.Ar msg . -See -.Xr mmsg 7 -for the message argument syntax. -.Sh MENU COMMANDS -.Bl -tag -width 2n -.It Ic s -Send the mail. -The MIME version will be used when one has been created. -.It Ic c -Cancel sending and quit -.Nm -after displaying the file name of the draft. -.It Ic m -Run -.Xr mmime 1 -on the draft, and show the result of -.Ic mshow -t . -.It Ic e -Re-run the editor on the draft. -.El -.Sh ENVIRONMENT -.Bl -tag -width Ds -.It Ev EDITOR -Editor used to compose mail. -.El -.Sh FILES -.Bl -tag -width Ds -.It Pa snd.* -Draft messages (kept in current directory) -.It Pa ~/.mblaze/headers -Default headers for each mail. -(Put your -.Sq Li From\&: -line there.) -.It Pa ~/.signature -Default signature. -.El -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Xr mmime 1 , -.Xr mmsg 7 -.Sh AUTHORS -.An Christian Neukirchen Aq Mt chneukirchen@gmail.com -.Sh LICENSE -.Nm -is in the public domain. -.Pp -To the extent possible under law, -the creator of this work -has waived all copyright and related or -neighboring rights to this work. -.Pp -.Lk http://creativecommons.org/publicdomain/zero/1.0/ diff --git a/man/mrep.1 b/man/mrep.1 @@ -0,0 +1 @@ +.so man1/mcom.1 diff --git a/mcom b/mcom @@ -0,0 +1,167 @@ +#!/bin/sh +# mcom [TO] - compose mail + +commajoin() { + sed ':a;N;s/\n/, /;$!b a' +} + +reffmt() { + sed 's/^[^<]*//g;s/[^>]*$//g;s/>[^<]*</>\n</g' | uniq | sed 's/^/ /' +} + +msgid() { + mgenmid 2>/dev/null | sed 's/^/Message-Id: /' +} + +msgdate() { + echo -n "Date: " + mdate +} + +outbox=$(mhdr -h outbox ~/.mblaze/profile) +if [ -z "$outbox" ]; then + i=0 + while [ -f "snd.$i" ]; do + i=$((i+1)) + done + draft="snd.$i" + draftmime="./snd.$i.mime" +else + draft="$(true | mdeliver -v -XD "$outbox")" + if [ -z "$draft" ]; then + echo "$0: failed to create draft in outbox $outbox." 1>&2 + exit 1 + fi + draftmime="$(echo $draft | sed 's,\(.*\)/cur/,\1/tmp/mime-,')" +fi + +{ + case "$0" in + *mcom*) + echo -n "To: $1" + [ "$#" -ge 1 ] && shift + for rcpt; do + echo -n ", $rcpt" + done + echo + echo "Cc: " + echo "Bcc: " + echo "Subject: " + from=$(mhdr -h local-mailbox ~/.mblaze/profile) + [ "$from" ] && echo "From: $from" + cat ~/.mblaze/headers 2>/dev/null + msgid + msgdate + echo + echo + ;; + *mrep*) + [ "$#" -eq 0 ] && set -- . + to=$(mhdr -h reply-to "$1") + [ -z "$to" ] && to=$(mhdr -h from "$1") + echo "To: $to" + echo "Cc: $(mhdr -d -A -h to:cc: "$1" | commajoin)" + echo "Bcc: " + s=$(mhdr -d -h subject "$1") + os= + while [ "$os" != "$s" ]; do + os=$s + s=${s# } + s=${s#[Rr][Ee]:} + s=${s#[Aa][Ww]:} + s=${s#[Ff][Ww][Dd]:} + done + echo "Subject: Re: $s" + cat ~/.mblaze/headers 2>/dev/null + mid=$(mhdr -h message-id "$1") + if [ "$mid" ]; then + echo -n "References:" + { + mhdr -h references "$1" + printf "%s\n" "$mid" + } | reffmt + echo "In-Reply-To: $mid" + fi + msgid + msgdate + echo + + mquote "$1" + echo + esac + + if [ -f ~/.signature ]; then + printf '%s\n' '-- ' + cat ~/.signature + fi +} >$draft + +c=e +while :; do + case "$c" in + s|send) + if [ -e $draftmime ]; then + if [ $draft -ot $draftmime ]; then + if sendmail -t <$draftmime; then + if [ "$outbox" ]; then + mv $draftmime $draft + mflag -d $draft + else + rm $draft $draftmime + fi + exit 0 + else + echo "mcom: sendmail failed, kept draft $draft" + exit 2 + fi + else + echo "mcom: re-run mmime first." + c= + fi + else + if mmime -c <$draft; then + if sendmail -t <$draft; then + if [ "$outbox" ]; then + mflag -d $draft + else + rm $draft + fi + exit 0 + else + echo "mcom: sendmail failed, kept draft $draft" + exit 2 + fi + else + echo "mcom: message needs to be MIME-encoded first." + c= + fi + fi + ;; + c|cancel) + echo "mcom: cancelled draft $draft" + exit 1 + ;; + m|mime) + ( + IFS=' +' + msed '/attach/d' $draft + for f in $(mhdr -M -h attach $draft); do + echo "#$(file -Lbi $f | sed 's/ //g') $f" + done + ) | tee /tmp/v | mmime >$draftmime + mshow -t $draftmime + c= + ;; + e|edit) + c= + if ! ${EDITOR:-vi} $draft; then + c=c + fi + ;; + *) + echo -n "What now? ([s]end, [c]ancel, [e]dit, [m]ime) " + read -r c + ;; + esac +done diff --git a/mcomp b/mcomp @@ -1,167 +0,0 @@ -#!/bin/sh -# mcomp [TO] - compose mail - -commajoin() { - sed ':a;N;s/\n/, /;$!b a' -} - -reffmt() { - sed 's/^[^<]*//g;s/[^>]*$//g;s/>[^<]*</>\n</g' | uniq | sed 's/^/ /' -} - -msgid() { - mgenmid 2>/dev/null | sed 's/^/Message-Id: /' -} - -msgdate() { - echo -n "Date: " - mdate -} - -outbox=$(mhdr -h outbox ~/.mblaze/profile) -if [ -z "$outbox" ]; then - i=0 - while [ -f "snd.$i" ]; do - i=$((i+1)) - done - draft="snd.$i" - draftmime="./snd.$i.mime" -else - draft="$(true | mdeliver -v -XD "$outbox")" - if [ -z "$draft" ]; then - echo "$0: failed to create draft in outbox $outbox." 1>&2 - exit 1 - fi - draftmime="$(echo $draft | sed 's,\(.*\)/cur/,\1/tmp/mime-,')" -fi - -{ - case "$0" in - *mcomp*) - echo -n "To: $1" - [ "$#" -ge 1 ] && shift - for rcpt; do - echo -n ", $rcpt" - done - echo - echo "Cc: " - echo "Bcc: " - echo "Subject: " - from=$(mhdr -h local-mailbox ~/.mblaze/profile) - [ "$from" ] && echo "From: $from" - cat ~/.mblaze/headers 2>/dev/null - msgid - msgdate - echo - echo - ;; - *mrepl*) - [ "$#" -eq 0 ] && set -- . - to=$(mhdr -h reply-to "$1") - [ -z "$to" ] && to=$(mhdr -h from "$1") - echo "To: $to" - echo "Cc: $(mhdr -d -A -h to:cc: "$1" | commajoin)" - echo "Bcc: " - s=$(mhdr -d -h subject "$1") - os= - while [ "$os" != "$s" ]; do - os=$s - s=${s# } - s=${s#[Rr][Ee]:} - s=${s#[Aa][Ww]:} - s=${s#[Ff][Ww][Dd]:} - done - echo "Subject: Re: $s" - cat ~/.mblaze/headers 2>/dev/null - mid=$(mhdr -h message-id "$1") - if [ "$mid" ]; then - echo -n "References:" - { - mhdr -h references "$1" - printf "%s\n" "$mid" - } | reffmt - echo "In-Reply-To: $mid" - fi - msgid - msgdate - echo - - mquote "$1" - echo - esac - - if [ -f ~/.signature ]; then - printf '%s\n' '-- ' - cat ~/.signature - fi -} >$draft - -c=e -while :; do - case "$c" in - s|send) - if [ -e $draftmime ]; then - if [ $draft -ot $draftmime ]; then - if sendmail -t <$draftmime; then - if [ "$outbox" ]; then - mv $draftmime $draft - mflag -d $draft - else - rm $draft $draftmime - fi - exit 0 - else - echo "mcomp: sendmail failed, kept draft $draft" - exit 2 - fi - else - echo "mcomp: re-run mmime first." - c= - fi - else - if mmime -c <$draft; then - if sendmail -t <$draft; then - if [ "$outbox" ]; then - mflag -d $draft - else - rm $draft - fi - exit 0 - else - echo "mcomp: sendmail failed, kept draft $draft" - exit 2 - fi - else - echo "mcomp: message needs to be MIME-encoded first." - c= - fi - fi - ;; - c|cancel) - echo "mcomp: cancelled draft $draft" - exit 1 - ;; - m|mime) - ( - IFS=' -' - msed '/attach/d' $draft - for f in $(mhdr -M -h attach $draft); do - echo "#$(file -Lbi $f | sed 's/ //g') $f" - done - ) | tee /tmp/v | mmime >$draftmime - mshow -t $draftmime - c= - ;; - e|edit) - c= - if ! ${EDITOR:-vi} $draft; then - c=c - fi - ;; - *) - echo -n "What now? ([s]end, [c]ancel, [e]dit, [m]ime) " - read -r c - ;; - esac -done diff --git a/mrep b/mrep @@ -0,0 +1 @@ +mcom+ \ No newline at end of file diff --git a/mrepl b/mrepl @@ -1 +0,0 @@ -mcomp- \ No newline at end of file