mailto: handle bcc and body fields

Enable handling of bcc and body fields in mailto links

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-03-18 11:05:26 -05:00 committed by Robin Jarry
parent d39da95f73
commit 40d298b8d8
1 changed files with 10 additions and 0 deletions

View File

@ -525,6 +525,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
}
var subject string
var body string
h := &mail.Header{}
to, err := mail.ParseAddressList(addr.Opaque)
if err != nil && addr.Opaque != "" {
@ -533,6 +534,14 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
h.SetAddressList("to", to)
for key, vals := range addr.Query() {
switch strings.ToLower(key) {
case "bcc":
list, err := mail.ParseAddressList(strings.Join(vals, ","))
if err != nil {
break
}
h.SetAddressList("Bcc", list)
case "body":
body = strings.Join(vals, "\n")
case "cc":
list, err := mail.ParseAddressList(strings.Join(vals, ","))
if err != nil {
@ -561,6 +570,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
if err != nil {
return nil
}
composer.SetContents(strings.NewReader(body))
composer.FocusSubject()
title := "New email"
if subject != "" {