diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | commands/compose/send.go | 46 | ||||
-rw-r--r-- | doc/aerc-config.5.scd | 2 | ||||
-rw-r--r-- | doc/aerc-imap.5.scd | 2 | ||||
-rw-r--r-- | doc/aerc-sendmail.5.scd | 31 | ||||
-rw-r--r-- | doc/aerc-smtp.5.scd | 2 | ||||
-rw-r--r-- | doc/aerc.1.scd | 2 |
7 files changed, 74 insertions, 14 deletions
@@ -31,6 +31,7 @@ DOCS := \ aerc-config.5 \ aerc-imap.5 \ aerc-maildir.5 \ + aerc-sendmail.5 \ aerc-smtp.5 \ aerc-tutorial.7 @@ -61,6 +62,7 @@ install: all install -m644 aerc-config.5 $(MANDIR)/man5/aerc-config.5 install -m644 aerc-imap.5 $(MANDIR)/man5/aerc-imap.5 install -m644 aerc-maildir.5 $(MANDIR)/man5/aerc-maildir.5 + install -m644 aerc-sendmail.5 $(MANDIR)/man5/aerc-sendmail.5 install -m644 aerc-smtp.5 $(MANDIR)/man5/aerc-smtp.5 install -m644 aerc-tutorial.7 $(MANDIR)/man7/aerc-tutorial.7 install -m644 config/accounts.conf $(SHAREDIR)/accounts.conf @@ -81,6 +83,7 @@ uninstall: $(RM) $(MANDIR)/man5/aerc-config.5 $(RM) $(MANDIR)/man5/aerc-imap.5 $(RM) $(MANDIR)/man5/aerc-maildir.5 + $(RM) $(MANDIR)/man5/aerc-sendmail.5 $(RM) $(MANDIR)/man5/aerc-smtp.5 $(RM) $(MANDIR)/man7/aerc-tutorial.7 $(RM) -r $(SHAREDIR) diff --git a/commands/compose/send.go b/commands/compose/send.go index 26df82a4..0574075e 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -6,6 +6,7 @@ import ( "io" "net/mail" "net/url" + "os/exec" "strings" "time" @@ -56,14 +57,16 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error { scheme string auth string = "plain" ) - parts := strings.Split(uri.Scheme, "+") - if len(parts) == 1 { - scheme = parts[0] - } else if len(parts) == 2 { - scheme = parts[0] - auth = parts[1] - } else { - return fmt.Errorf("Unknown transfer protocol %s", uri.Scheme) + if uri.Scheme != "" { + parts := strings.Split(uri.Scheme, "+") + if len(parts) == 1 { + scheme = parts[0] + } else if len(parts) == 2 { + scheme = parts[0] + auth = parts[1] + } else { + return fmt.Errorf("Unknown transfer protocol %s", uri.Scheme) + } } header, rcpts, err := composer.PrepareHeader() @@ -102,7 +105,7 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error { starttls = starttls_ == "yes" } - sendAsync := func() (int, error) { + smtpAsync := func() (int, error) { switch scheme { case "smtp": host := uri.Host @@ -154,7 +157,6 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error { defer conn.Close() } - // TODO: sendmail if saslClient != nil { if err = conn.Auth(saslClient); err != nil { return 0, errors.Wrap(err, "conn.Auth") @@ -180,6 +182,30 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error { return int(ctr.Count()), nil } + sendmailAsync := func() (int, error) { + cmd := exec.Command(uri.Path, rcpts...) + wc, err := cmd.StdinPipe() + if err != nil { + return 0, errors.Wrap(err, "cmd.StdinPipe") + } + defer wc.Close() + go cmd.Run() + ctr := datacounter.NewWriterCounter(wc) + composer.WriteMessage(header, ctr) + return int(ctr.Count()), nil + } + + sendAsync := func() (int, error) { + switch scheme { + case "smtp": + case "smtps": + return smtpAsync() + case "": + return sendmailAsync() + } + return 0, errors.New("Unknown scheme") + } + go func() { aerc.SetStatus("Sending...") nbytes, err := sendAsync() diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 592b7afd..72823115 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -417,7 +417,7 @@ following special keys are supported: # SEE ALSO -*aerc*(1) *aerc-imap*(5) *aerc-smtp*(5) *aerc-maildir*(5) +*aerc*(1) *aerc-imap*(5) *aerc-smtp*(5) *aerc-maildir*(5) *aerc-sendmail*(5) # AUTHORS diff --git a/doc/aerc-imap.5.scd b/doc/aerc-imap.5.scd index 4307238e..a34855f0 100644 --- a/doc/aerc-imap.5.scd +++ b/doc/aerc-imap.5.scd @@ -63,7 +63,7 @@ available: # SEE ALSO -*aerc*(1) *aerc-config*(5) *aerc-smtp*(5) +*aerc*(1) *aerc-config*(5) # AUTHORS diff --git a/doc/aerc-sendmail.5.scd b/doc/aerc-sendmail.5.scd new file mode 100644 index 00000000..90118fbb --- /dev/null +++ b/doc/aerc-sendmail.5.scd @@ -0,0 +1,31 @@ +aerc-sendmail(5) + +# NAME + +aerc-sendmail - sendmail configuration for *aerc*(1) + +# SYNOPSIS + +aerc can defer to sendmail for the delivery of outgoing messages. + +# CONFIGURATION + +In accounts.conf (see *aerc-config*(5)), the following sendmail-specific +options are available: + +*outgoing* + /path/to/sendmail + + This should be set to the path to the sendmail binary you wish to use, + which is generally /usr/bin/sendmail. aerc will execute it with a list of + recipients on the command line and pipe the message to deliver to stdin. + +# SEE ALSO + +*aerc*(1) *aerc-config*(5) + +# AUTHORS + +Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other open +source contributors. For more information about aerc development, see +https://git.sr.ht/~sircmpwn/aerc. diff --git a/doc/aerc-smtp.5.scd b/doc/aerc-smtp.5.scd index 15e03de2..e4550010 100644 --- a/doc/aerc-smtp.5.scd +++ b/doc/aerc-smtp.5.scd @@ -51,7 +51,7 @@ available: # SEE ALSO -*aerc*(1) *aerc-config*(5) *aerc-smtp*(5) +*aerc*(1) *aerc-config*(5) # AUTHORS diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index 7989ad93..8401d644 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -246,7 +246,7 @@ write log messages to that file: # SEE ALSO *aerc-config*(5) *aerc-imap*(5) *aerc-smtp*(5) *aerc-maildir*(5) -*aerc-tutorial*(7) +*aerc-sendmail*(5) *aerc-tutorial*(7) # AUTHORS |