# addrs.patch -rw-r--r-- 1.2 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 92dc31bad0dc69fa96b04242b635fee051ed1965 Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Wed, 5 Jun 2019 13:58:07 -0400
Subject: [PATCH] Use SetAddressList for From header

---
 widgets/compose.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/widgets/compose.go b/widgets/compose.go
index 9bd5350..26b567f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -217,8 +217,16 @@ func (c *Composer) PrepareHeader() (*mail.Header, []string, error) {
 	if date, err := header.Date(); err != nil || date == (time.Time{}) {
 		header.SetDate(time.Now())
 	}
-	if from, _ := mhdr.Text("From"); from == "" {
-		mhdr.SetText("From", c.headers.from.input.String())
+	from := c.headers.from.input.String()
+	from_addrs, err := gomail.ParseAddressList(from)
+	if err != nil {
+		return nil, nil, errors.Wrapf(err, "ParseAddressList(%s)", from)
+	} else {
+		var simon_from []*mail.Address
+		for _, addr := range from_addrs {
+			simon_from = append(simon_from, (*mail.Address)(addr))
+		}
+		header.SetAddressList("From", simon_from)
 	}
 	if to := c.headers.to.input.String(); to != "" {
 		// Dammit Simon, this branch is 3x as long as it ought to be because
-- 
2.21.0