From e90d4579ae107f89e20669781e4bf4834e6e6b9a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 3 Dec 2019 18:46:18 +0100 Subject: [PATCH] Add basic support for multiple recipients --- server.go | 5 ++--- strconv.go | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index af84d4f..8e3730c 100644 --- a/server.go +++ b/server.go @@ -271,9 +271,8 @@ func handleCompose(ectx echo.Context) error { } if ctx.Request().Method == http.MethodPost { - // TODO: parse address lists from := ctx.FormValue("from") - to := ctx.FormValue("to") + to := parseAddressList(ctx.FormValue("to")) subject := ctx.FormValue("subject") text := ctx.FormValue("text") @@ -289,7 +288,7 @@ func handleCompose(ectx echo.Context) error { } msg.From = from - msg.To = []string{to} + msg.To = to msg.Subject = subject msg.Text = text diff --git a/strconv.go b/strconv.go index b34241d..14c0c27 100644 --- a/strconv.go +++ b/strconv.go @@ -47,3 +47,11 @@ func parsePartPath(s string) ([]int, error) { } return path, nil } + +func parseAddressList(s string) []string { + l := strings.Split(s, ",") + for i, addr := range l { + l[i] = strings.TrimSpace(addr) + } + return l +}