diff options
author | Robin Jarry <robin@jarry.cc> | 2023-08-20 22:09:01 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-26 21:41:05 +0200 |
commit | 459724889a62d65ff09ee15d6b6bd98b650e1cb7 (patch) | |
tree | 83d2ea8ae69ddad9baaae920fc3a78f28821f818 /widgets | |
parent | a78814a9aa5570e52cc3f31b159ddd6f04fbbcc4 (diff) | |
download | aerc-459724889a62d65ff09ee15d6b6bd98b650e1cb7.tar.gz |
wizard: add sendmail support
Allow users to configure sendmail as outgoing protocol.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Tristan Partin <tristan@partin.io>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account-wizard.go | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index 4e65439e..266b86f5 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -158,6 +158,7 @@ const ( MAILDIRPP = "Maildir++" NOTMUCH = "notmuch" SMTP = "SMTP" + SENDMAIL = "sendmail" // transports SSL_TLS = "SSL/TLS" OAUTH = "SSL/TLS+OAUTHBEARER" @@ -168,7 +169,7 @@ const ( var ( sources = []string{IMAP, JMAP, MAILDIR, MAILDIRPP, NOTMUCH} - outgoings = []string{SMTP, JMAP} + outgoings = []string{SMTP, JMAP, SENDMAIL} transports = []string{SSL_TLS, OAUTH, XOAUTH, STARTTLS, INSECURE} ) @@ -327,7 +328,7 @@ Press <Tab> and <Shift+Tab> to cycle between each field in this form, or <Ctrl+j outgoing.AddField("Username", wizard.outgoingUsername) outgoing.AddField("Password", wizard.outgoingPassword) outgoing.AddField( - "Server address (e.g. 'mail.example.org' or 'mail.example.org:1313')", + "Server address (or path to sendmail)", wizard.outgoingServer, ) outgoing.AddField("Transport security", wizard.outgoingTransport) @@ -452,6 +453,23 @@ func (wizard *AccountWizard) finish(tutorial bool) { return } } + if wizard.outgoingProtocol.Selected() == SENDMAIL { + path := wizard.outgoingServer.String() + if p, err := homedir.Expand(path); err == nil { + path = p + } + s, err := os.Stat(path) + if err == nil && !s.Mode().IsRegular() { + err = fmt.Errorf("%s: Not a regular file", s.Name()) + } + if err == nil { + err = unix.Access(path, unix.X_OK) + } + if err != nil { + wizard.errorFor(wizard.outgoingServer, err) + return + } + } file, err := ini.Load(accountsConf) if err != nil { @@ -680,6 +698,12 @@ func (wizard *AccountWizard) outgoingUri() url.URL { default: scheme = "jmap" } + case SENDMAIL: + scheme = "" + path = host + path + host = "" + user = "" + pass = "" } uri, clean := makeURLs(scheme, host, path, user, pass) @@ -864,6 +888,10 @@ func (wizard *AccountWizard) autofill() { } case JMAP: wizard.outgoingTransport.Select(SSL_TLS) + case SENDMAIL: + wizard.outgoingServer.Set("/usr/sbin/sendmail") + wizard.outgoingUsername.Set("") + wizard.outgoingPassword.Set("") } } } |