Open epelc opened 6 years ago
For reference here are the sparkpost docs requiring no RFC 2047 encoding of header fields. I believe they do this because they are allows template/substitution variables within their headers.
Each header value is expected in the UTF-8 charset without RFC2047 encoding. https://developers.sparkpost.com/api/transmissions/#header-header-notes
/cc @bradfitz
Could you provide some examples?
Any suggested method name?
I just looked through the rfc(5322) a bit and it refers to this syntax as name-addr
name-addr = [display-name] angle-addr Section 3.4 https://tools.ietf.org/html/rfc5322#section-3
Maybe func (*Address) NameAddr() string
I'm pretty sure go is against putting rfc numbers in names of things besides the time formatting vars and I don't think there are competing standards since rfc 2044 is just an encoding and not a formatting rfc afaik.
Name sounds fine. Feel free to send a change.
Change https://golang.org/cl/139077 mentions this issue: net/mail: adds
NameAddr() stringmethod to return UTF8 RFC 5322
name-addrformatted addresses
RFC 6532 section 3.2 specifically allows this, so I believe it should be documented as such; RFC 5322 on itself doesn't specify raw UTF-8 in addresses.
@epelc Any update on this? Is there still a desire for this to get in 1.14? I see some unaddressed comments on the CL.
The
Address.String()
method sometimes encodes as RFC 2047 after the 5322 formatting depending on the characters in the address. However some services (Ala sparkpost transmission api header fields) want RFC 5322 formatted addresses in UTF8 and not encoded as RFC 2047.I'm not sure if the [quoting]( I don't think you can easily or safely reverse the 2047 encoding via the mime package because the code has two paths for quoting. I think you'd want a
String()
method which basically returned before this.) is a part of rfc 2047 or not.I know this isn't required to the use the api but I'm wondering if there are any other use case which wouldn't require RFC 2047 encoding as well. If so it might be worthwhile to add an additional string/format function.