aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--config/accounts.go1
-rw-r--r--doc/aerc-accounts.5.scd6
-rw-r--r--go.mod4
-rw-r--r--go.sum11
-rw-r--r--widgets/compose.go24
6 files changed, 42 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae5b98f6..50324992 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
`/usr/bin/colorize`).
- `:export-mbox` only exports marked messages, if any. Otherwise it exports
everything, as usual.
+- The local hostname is no longer exposed in outgoing `Message-Id` headers by
+ default. Legacy behaviour can be restored by setting `send-with-hostname
+ = true` in `accounts.conf`.
### Deprecated
diff --git a/config/accounts.go b/config/accounts.go
index a8c2b9bf..3a506e6a 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -91,6 +91,7 @@ type AccountConfig struct {
FoldersSort []string `ini:"folders-sort" delim:","`
AddressBookCmd string `ini:"address-book-cmd"`
SendAsUTC bool `ini:"send-as-utc" default:"false"`
+ SendWithHostname bool `ini:"send-with-hostname" default:"false"`
LocalizedRe *regexp.Regexp `ini:"subject-re-pattern" default:"(?i)^((AW|RE|SV|VS|ODP|R): ?)+"`
// CheckMail
diff --git a/doc/aerc-accounts.5.scd b/doc/aerc-accounts.5.scd
index b8871d9b..3b6ad030 100644
--- a/doc/aerc-accounts.5.scd
+++ b/doc/aerc-accounts.5.scd
@@ -204,6 +204,12 @@ Note that many of these configuration options are written for you, such as
Default: _false_
+*send-with-hostname* = _true_|_false_
+ Uses the local hostname in outgoing Message-Id headers instead of your
+ email address domain name.
+
+ Default: _false_
+
*source* = _<uri>_
Specifies the source for reading incoming emails on this account. This key
is required for all accounts. It should be a connection string, and the
diff --git a/go.mod b/go.mod
index 3a21656e..347b16aa 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
github.com/emersion/go-imap-sortthread v1.2.0
github.com/emersion/go-maildir v0.3.0
github.com/emersion/go-mbox v1.0.3
- github.com/emersion/go-message v0.16.0
+ github.com/emersion/go-message v0.17.0
github.com/emersion/go-msgauth v0.6.6
github.com/emersion/go-pgpmail v0.2.0
github.com/emersion/go-sasl v0.0.0-20220912192320-0145f2c60ead
@@ -56,7 +56,7 @@ require (
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/term v0.7.0 // indirect
- golang.org/x/text v0.9.0 // indirect
+ golang.org/x/text v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
diff --git a/go.sum b/go.sum
index bee2b079..246fe846 100644
--- a/go.sum
+++ b/go.sum
@@ -40,8 +40,8 @@ github.com/emersion/go-mbox v1.0.3/go.mod h1:Yp9IVuuOYLEuMv4yjgDHvhb5mHOcYH6x92O
github.com/emersion/go-message v0.11.1/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY=
github.com/emersion/go-message v0.11.2/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
-github.com/emersion/go-message v0.16.0 h1:uZLz8ClLv3V5fSFF/fFdW9jXjrZkXIpE1Fn8fKx7pO4=
-github.com/emersion/go-message v0.16.0/go.mod h1:pDJDgf/xeUIF+eicT6B/hPX/ZbEorKkUMPOxrPVG2eQ=
+github.com/emersion/go-message v0.17.0 h1:NIdSKHiVUx4qKqdd0HyJFD41cW8iFguM2XJnRZWQH04=
+github.com/emersion/go-message v0.17.0/go.mod h1:/9Bazlb1jwUNB0npYYBsdJ2EMOiiyN3m5UVHbY7GoNw=
github.com/emersion/go-milter v0.3.3/go.mod h1:ablHK0pbLB83kMFBznp/Rj8aV+Kc3jw8cxzzmCNLIOY=
github.com/emersion/go-msgauth v0.6.6 h1:buv5lL8v/3v4RpHnQFS2IPhE3nxSRX+AxnrEJbDbHhA=
github.com/emersion/go-msgauth v0.6.6/go.mod h1:A+/zaz9bzukLM6tRWRgJ3BdrBi+TFKTvQ3fGMFOI9SM=
@@ -157,11 +157,13 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJu
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
@@ -170,6 +172,7 @@ golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -195,8 +198,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
-golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
+golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
diff --git a/widgets/compose.go b/widgets/compose.go
index f682fe5c..05d06a7f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -136,6 +136,7 @@ func (c *Composer) SwitchAccount(newAcct *AccountView) error {
}
// ensure that from header is updated, so remove it
c.header.Del("from")
+ c.header.Del("message-id")
// update entire composer with new the account
if err := c.setupFor(newAcct); err != nil {
return err
@@ -845,10 +846,13 @@ func (c *Composer) PrepareHeader() (*mail.Header, error) {
// control headers not normally set by the user
// repeated calls to PrepareHeader should be a noop
if !c.header.Has("Message-Id") {
- err := c.header.GenerateMessageID()
+ hostname, err := getMessageIdHostname(c)
if err != nil {
return nil, err
}
+ if err := c.header.GenerateMessageIDWithHostname(hostname); err != nil {
+ return nil, err
+ }
}
// update the "Date" header every time PrepareHeader is called
@@ -861,6 +865,21 @@ func (c *Composer) PrepareHeader() (*mail.Header, error) {
return c.header, nil
}
+func getMessageIdHostname(c *Composer) (string, error) {
+ if c.acctConfig.SendWithHostname {
+ return os.Hostname()
+ }
+ addrs, err := c.header.AddressList("from")
+ if err != nil {
+ return "", err
+ }
+ _, domain, found := strings.Cut(addrs[0].Address, "@")
+ if !found {
+ return "", fmt.Errorf("Invalid address %q", addrs[0])
+ }
+ return domain, nil
+}
+
func (c *Composer) parseEmbeddedHeader() (*mail.Header, error) {
_, err := c.email.Seek(0, io.SeekStart)
if err != nil {
@@ -1531,6 +1550,9 @@ func (he *headerEditor) storeValue() {
default:
he.header.SetText(he.name, val)
}
+ if strings.ToLower(he.name) == "from" {
+ he.header.Del("message-id")
+ }
}
func (he *headerEditor) Draw(ctx *ui.Context) {