aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/account/compose.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 4884b113..fc7617ec 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -2,9 +2,14 @@ package account
import (
"errors"
+ "fmt"
+ "io"
+ gomail "net/mail"
"regexp"
"strings"
+ "github.com/emersion/go-message/mail"
+
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -38,9 +43,17 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
template = aerc.Config().Templates.NewMessage
}
+ msg, err := gomail.ReadMessage(strings.NewReader(body))
+ if errors.Is(err, io.EOF) { // completely empty
+ msg = &gomail.Message{Body: strings.NewReader("")}
+ } else if err != nil {
+ return fmt.Errorf("mail.ReadMessage: %w", err)
+ }
+ headers := mail.HeaderFromMap(msg.Header)
+
composer, err := widgets.NewComposer(aerc, acct,
aerc.Config(), acct.AccountConfig(), acct.Worker(),
- template, nil, models.OriginalMail{})
+ template, &headers, models.OriginalMail{})
if err != nil {
return err
}
@@ -56,7 +69,7 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
go func() {
defer logging.PanicHandler()
- composer.AppendContents(strings.NewReader(body))
+ composer.AppendContents(msg.Body)
}()
return nil
}