aboutsummaryrefslogtreecommitdiffstats
path: root/commands/compose
diff options
context:
space:
mode:
Diffstat (limited to 'commands/compose')
-rw-r--r--commands/compose/header.go7
-rw-r--r--commands/compose/postpone.go2
-rw-r--r--commands/compose/send.go32
3 files changed, 32 insertions, 9 deletions
diff --git a/commands/compose/header.go b/commands/compose/header.go
index 5188a8a2..dd0adee9 100644
--- a/commands/compose/header.go
+++ b/commands/compose/header.go
@@ -57,18 +57,17 @@ func (Header) Execute(aerc *widgets.Aerc, args []string) error {
composer, _ := aerc.SelectedTab().(*widgets.Composer)
if !force {
- headers, _, err := composer.PrepareHeader()
+ headers, err := composer.PrepareHeader()
if err != nil {
return err
}
- if headers.Has(strings.Title(args[optind])) {
+ if headers.Has(args[optind]) {
return fmt.Errorf("Header %s already exists", args[optind])
}
}
- composer.AddEditor(strings.Title(args[optind]),
- strings.Join(args[optind+1:], " "), false)
+ composer.AddEditor(args[optind], strings.Join(args[optind+1:], " "), false)
return nil
}
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index 60c9df1a..365b683f 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -40,7 +40,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
aerc.Logger().Println("Postponing mail")
- header, _, err := composer.PrepareHeader()
+ header, err := composer.PrepareHeader()
if err != nil {
return errors.Wrap(err, "PrepareHeader")
}
diff --git a/commands/compose/send.go b/commands/compose/send.go
index abbcb544..70446dab 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -4,7 +4,6 @@ import (
"crypto/tls"
"fmt"
"io"
- "net/mail"
"net/url"
"os/exec"
"strings"
@@ -17,9 +16,11 @@ import (
"github.com/pkg/errors"
"git.sr.ht/~sircmpwn/aerc/lib"
+ "git.sr.ht/~sircmpwn/aerc/lib/format"
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets"
"git.sr.ht/~sircmpwn/aerc/worker/types"
+ "github.com/emersion/go-message/mail"
"golang.org/x/oauth2"
)
@@ -71,15 +72,19 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
}
}
- header, rcpts, err := composer.PrepareHeader()
+ header, err := composer.PrepareHeader()
if err != nil {
return errors.Wrap(err, "PrepareHeader")
}
+ rcpts, err := listRecipients(header)
+ if err != nil {
+ return errors.Wrap(err, "listRecipients")
+ }
if config.From == "" {
return errors.New("No 'From' configured for this account")
}
- from, err := mail.ParseAddress(config.From)
+ from, err := format.ParseAddress(config.From)
if err != nil {
return errors.Wrap(err, "ParseAddress(config.From)")
}
@@ -288,7 +293,12 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
composer.Close()
}
})
- header, _, _ := composer.PrepareHeader()
+ header, err := composer.PrepareHeader()
+ if err != nil {
+ aerc.PushError(" " + err.Error())
+ w.Close()
+ return
+ }
composer.WriteMessage(header, w)
w.Close()
} else {
@@ -299,3 +309,17 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
}()
return nil
}
+
+func listRecipients(h *mail.Header) ([]string, error) {
+ var rcpts []string
+ for _, key := range []string{"to", "cc", "bcc"} {
+ list, err := h.AddressList(key)
+ if err != nil {
+ return nil, err
+ }
+ for _, addr := range list {
+ rcpts = append(rcpts, addr.Address)
+ }
+ }
+ return rcpts, nil
+}