rss email digests over ssh because you're a cool kid herald.dunkirk.sh
go rss rss-reader ssh charm

chore: fix email deliverability issues

dunkirk.sh d53c127d 7e06f55a

verified
+11 -2
+11 -2
email/send.go
··· 2 2 3 3 import ( 4 4 "bytes" 5 + "crypto/rand" 5 6 "crypto/rsa" 6 7 "crypto/tls" 7 8 "crypto/x509" 9 + "encoding/hex" 8 10 "encoding/pem" 9 11 "fmt" 10 12 "mime" ··· 196 198 headers["Subject"] = mime.QEncoding.Encode("utf-8", subject) 197 199 headers["MIME-Version"] = "1.0" 198 200 headers["Content-Type"] = fmt.Sprintf("multipart/alternative; boundary=%q", boundary) 201 + headers["Date"] = time.Now().Format(time.RFC1123Z) 202 + headers["Message-ID"] = fmt.Sprintf("<%d.%s@%s>", time.Now().Unix(), generateMessageIDToken(), m.cfg.Host) 199 203 200 204 // RFC 2369 list headers 201 205 headers["List-Id"] = fmt.Sprintf("<herald.%s>", m.cfg.Host) ··· 209 213 headers["List-Unsubscribe-Post"] = "List-Unsubscribe=One-Click" 210 214 } 211 215 212 - // Bulk mail and auto-generated headers for better deliverability 216 + // Bulk mail headers for better deliverability 213 217 headers["Precedence"] = "bulk" 214 - headers["Auto-Submitted"] = "auto-generated" 215 218 headers["X-Mailer"] = "Herald" 216 219 217 220 var msg strings.Builder ··· 257 260 } 258 261 259 262 return m.sendWithSTARTTLS(addr, auth, to, messageBytes) 263 + } 264 + 265 + func generateMessageIDToken() string { 266 + b := make([]byte, 8) 267 + _, _ = rand.Read(b) 268 + return hex.EncodeToString(b) 260 269 } 261 270 262 271 func encodeQuotedPrintable(s string) string {