From d2d687478d055fa0acf2a6452cac324cc6bb54fb Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 8 Aug 2016 16:01:06 +0200 Subject: rename mcomp -> mcom, mrepl -> mrep mcomp is in mtools already. mfwd will be added in the future. --- 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 | 1 + mrepl | 1 - 10 files changed, 252 insertions(+), 251 deletions(-) create mode 100644 man/mcom.1 delete mode 100644 man/mcomp.1 create mode 100644 man/mrep.1 create mode 100755 mcom delete mode 100755 mcomp create mode 120000 mrep delete mode 120000 mrepl diff --git a/Makefile b/Makefile index 8004ca8..c1609c3 100644 --- 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 index 364a694..e85fab2 100644 --- 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 index 2f3133c..6e30c6b 100644 --- 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 new file mode 100644 index 0000000..5e4a15e --- /dev/null +++ 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 deleted file mode 100644 index 3eb129b..0000000 --- a/man/mcomp.1 +++ /dev/null @@ -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 new file mode 100644 index 0000000..04eb765 --- /dev/null +++ b/man/mrep.1 @@ -0,0 +1 @@ +.so man1/mcom.1 diff --git a/mcom b/mcom new file mode 100755 index 0000000..72269a8 --- /dev/null +++ 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/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 deleted file mode 100755 index a98aa93..0000000 --- a/mcomp +++ /dev/null @@ -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/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 new file mode 120000 index 0000000..5574ca9 --- /dev/null +++ b/mrep @@ -0,0 +1 @@ +mcom \ No newline at end of file diff --git a/mrepl b/mrepl deleted file mode 120000 index 0789f5f..0000000 --- a/mrepl +++ /dev/null @@ -1 +0,0 @@ -mcomp \ No newline at end of file -- cgit 1.4.1