aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-16 13:07:35 +0100
committerSimon Ser <contact@emersion.fr>2019-12-16 13:07:35 +0100
commit622f00fe063c454b4080ad47e8732bd0e9848e82 (patch)
tree85f2eea7329f867ca359d4f9513ab2cd6789ca46 /plugins
parentd01c85616a5de48896910de75c6a4533c6e71015 (diff)
downloadalps-622f00fe063c454b4080ad47e8732bd0e9848e82.tar.gz
alps-622f00fe063c454b4080ad47e8732bd0e9848e82.zip
Replace Session.ConnectSMTP with Session.DoSMTP
This gives more flexibility in Session for optimizations, e.g. keep the SMTP connection around for some time if possible.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/handlers.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/plugins/base/handlers.go b/plugins/base/handlers.go
index c96dabf..d0ba9ba 100644
--- a/plugins/base/handlers.go
+++ b/plugins/base/handlers.go
@@ -13,6 +13,7 @@ import (
"github.com/emersion/go-imap"
imapclient "github.com/emersion/go-imap/client"
"github.com/emersion/go-message"
+ "github.com/emersion/go-smtp"
"github.com/labstack/echo/v4"
)
@@ -257,7 +258,9 @@ func handleCompose(ectx echo.Context) error {
msg.Text = ctx.FormValue("text")
msg.InReplyTo = ctx.FormValue("in_reply_to")
- c, err := ctx.Session.ConnectSMTP()
+ err := ctx.Session.DoSMTP(func(c *smtp.Client) error {
+ return sendMessage(c, &msg)
+ })
if err != nil {
if _, ok := err.(koushin.AuthError); ok {
return echo.NewHTTPError(http.StatusForbidden, err)
@@ -265,14 +268,6 @@ func handleCompose(ectx echo.Context) error {
return err
}
- if err := sendMessage(c, &msg); err != nil {
- return err
- }
-
- if err := c.Quit(); err != nil {
- return fmt.Errorf("QUIT failed: %v", err)
- }
-
// TODO: append to IMAP Sent mailbox
return ctx.Redirect(http.StatusFound, "/mailbox/INBOX")