Implement sendmail support
This commit is contained in:
parent
7a3765a36b
commit
48758136c0
7 changed files with 74 additions and 14 deletions
3
Makefile
3
Makefile
|
@ -31,6 +31,7 @@ DOCS := \
|
||||||
aerc-config.5 \
|
aerc-config.5 \
|
||||||
aerc-imap.5 \
|
aerc-imap.5 \
|
||||||
aerc-maildir.5 \
|
aerc-maildir.5 \
|
||||||
|
aerc-sendmail.5 \
|
||||||
aerc-smtp.5 \
|
aerc-smtp.5 \
|
||||||
aerc-tutorial.7
|
aerc-tutorial.7
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ install: all
|
||||||
install -m644 aerc-config.5 $(MANDIR)/man5/aerc-config.5
|
install -m644 aerc-config.5 $(MANDIR)/man5/aerc-config.5
|
||||||
install -m644 aerc-imap.5 $(MANDIR)/man5/aerc-imap.5
|
install -m644 aerc-imap.5 $(MANDIR)/man5/aerc-imap.5
|
||||||
install -m644 aerc-maildir.5 $(MANDIR)/man5/aerc-maildir.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-smtp.5 $(MANDIR)/man5/aerc-smtp.5
|
||||||
install -m644 aerc-tutorial.7 $(MANDIR)/man7/aerc-tutorial.7
|
install -m644 aerc-tutorial.7 $(MANDIR)/man7/aerc-tutorial.7
|
||||||
install -m644 config/accounts.conf $(SHAREDIR)/accounts.conf
|
install -m644 config/accounts.conf $(SHAREDIR)/accounts.conf
|
||||||
|
@ -81,6 +83,7 @@ uninstall:
|
||||||
$(RM) $(MANDIR)/man5/aerc-config.5
|
$(RM) $(MANDIR)/man5/aerc-config.5
|
||||||
$(RM) $(MANDIR)/man5/aerc-imap.5
|
$(RM) $(MANDIR)/man5/aerc-imap.5
|
||||||
$(RM) $(MANDIR)/man5/aerc-maildir.5
|
$(RM) $(MANDIR)/man5/aerc-maildir.5
|
||||||
|
$(RM) $(MANDIR)/man5/aerc-sendmail.5
|
||||||
$(RM) $(MANDIR)/man5/aerc-smtp.5
|
$(RM) $(MANDIR)/man5/aerc-smtp.5
|
||||||
$(RM) $(MANDIR)/man7/aerc-tutorial.7
|
$(RM) $(MANDIR)/man7/aerc-tutorial.7
|
||||||
$(RM) -r $(SHAREDIR)
|
$(RM) -r $(SHAREDIR)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -56,14 +57,16 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
scheme string
|
scheme string
|
||||||
auth string = "plain"
|
auth string = "plain"
|
||||||
)
|
)
|
||||||
parts := strings.Split(uri.Scheme, "+")
|
if uri.Scheme != "" {
|
||||||
if len(parts) == 1 {
|
parts := strings.Split(uri.Scheme, "+")
|
||||||
scheme = parts[0]
|
if len(parts) == 1 {
|
||||||
} else if len(parts) == 2 {
|
scheme = parts[0]
|
||||||
scheme = parts[0]
|
} else if len(parts) == 2 {
|
||||||
auth = parts[1]
|
scheme = parts[0]
|
||||||
} else {
|
auth = parts[1]
|
||||||
return fmt.Errorf("Unknown transfer protocol %s", uri.Scheme)
|
} else {
|
||||||
|
return fmt.Errorf("Unknown transfer protocol %s", uri.Scheme)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header, rcpts, err := composer.PrepareHeader()
|
header, rcpts, err := composer.PrepareHeader()
|
||||||
|
@ -102,7 +105,7 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
starttls = starttls_ == "yes"
|
starttls = starttls_ == "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
sendAsync := func() (int, error) {
|
smtpAsync := func() (int, error) {
|
||||||
switch scheme {
|
switch scheme {
|
||||||
case "smtp":
|
case "smtp":
|
||||||
host := uri.Host
|
host := uri.Host
|
||||||
|
@ -154,7 +157,6 @@ func (_ Send) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: sendmail
|
|
||||||
if saslClient != nil {
|
if saslClient != nil {
|
||||||
if err = conn.Auth(saslClient); err != nil {
|
if err = conn.Auth(saslClient); err != nil {
|
||||||
return 0, errors.Wrap(err, "conn.Auth")
|
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
|
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() {
|
go func() {
|
||||||
aerc.SetStatus("Sending...")
|
aerc.SetStatus("Sending...")
|
||||||
nbytes, err := sendAsync()
|
nbytes, err := sendAsync()
|
||||||
|
|
|
@ -417,7 +417,7 @@ following special keys are supported:
|
||||||
|
|
||||||
# SEE ALSO
|
# 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
|
# AUTHORS
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ available:
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
*aerc*(1) *aerc-config*(5) *aerc-smtp*(5)
|
*aerc*(1) *aerc-config*(5)
|
||||||
|
|
||||||
# AUTHORS
|
# AUTHORS
|
||||||
|
|
||||||
|
|
31
doc/aerc-sendmail.5.scd
Normal file
31
doc/aerc-sendmail.5.scd
Normal file
|
@ -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.
|
|
@ -51,7 +51,7 @@ available:
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
*aerc*(1) *aerc-config*(5) *aerc-smtp*(5)
|
*aerc*(1) *aerc-config*(5)
|
||||||
|
|
||||||
# AUTHORS
|
# AUTHORS
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ write log messages to that file:
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
*aerc-config*(5) *aerc-imap*(5) *aerc-smtp*(5) *aerc-maildir*(5)
|
*aerc-config*(5) *aerc-imap*(5) *aerc-smtp*(5) *aerc-maildir*(5)
|
||||||
*aerc-tutorial*(7)
|
*aerc-sendmail*(5) *aerc-tutorial*(7)
|
||||||
|
|
||||||
# AUTHORS
|
# AUTHORS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue