Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: net/mail: parse group address #22014

Closed
minaevmike opened this issue Sep 25, 2017 · 5 comments
Closed

proposal: net/mail: parse group address #22014

minaevmike opened this issue Sep 25, 2017 · 5 comments

Comments

@minaevmike
Copy link
Contributor

@minaevmike minaevmike commented Sep 25, 2017

I want to add support for parsing group email addresses as defined in rfc5322(https://www.ietf.org/rfc/rfc5322.txt).

   address         =   mailbox / group
   mailbox         =   name-addr / addr-spec
   name-addr       =   [display-name] angle-addr
   angle-addr      =   [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
   group           =   display-name ":" [group-list] ";" [CFWS]
   display-name    =   phrase
   mailbox-list    =   (mailbox *("," mailbox)) / obs-mbox-list
   address-list    =   (address *("," address)) / obs-addr-list
   group-list      =   mailbox-list / CFWS / obs-group-list

First of all I would like to discuss the changes. Current strucutre of address is

type Address struct {
        Name    string // Proper name; may be empty.
        Address string // user@domain
}

These are possible implementations:

  1. Ignore groups at all; group-list is resolved into mailbost-list. But I have no idea how to handle group address in mail.ParseAddress because it returns single Address struct.

  2. Change Address struct into smth like:

type SingleAddress struct {
        Name    string // Proper name; may be empty.
        Address string // user@domain
}

type GroupAddress struct {
        Name string // group name
        Addresses []SingleAddress
}

type Address struct {
       SingleAddress
       IsGroup bool // true if address is group one
       GroupAddress GroupAddress
}

This implementation won't break backward compatibility, but Address struct becomes terrible.

  1. Add separate method for parsing group addresses.

So i would like to listen your thoughts about it.

@gopherbot gopherbot added this to the Proposal milestone Sep 25, 2017
@gopherbot gopherbot added the Proposal label Sep 25, 2017
@mvdan
Copy link
Member

@mvdan mvdan commented Sep 25, 2017

I assume this is different from ParseAddressList?

  1. Change ...

Not an option at the moment, as that would break the Go1 compatibility promise.

@mvdan
Copy link
Member

@mvdan mvdan commented Sep 25, 2017

This implementation won't break backward compatibility, but Address struct becomes terrible.

Sorry, I missed this bit. This still seems like a bad idea to me, too. And I would argue it would still break Go1, as the following would break:

_ = Address{Name: "Foo", Address: "foo@bar.com"}
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 25, 2017

Does anybody actually use group addresses?

@minaevmike
Copy link
Contributor Author

@minaevmike minaevmike commented Sep 25, 2017

@ianlancetaylor yes, for example postfix be default set empty group list if there is no To header http://www.postfix.org/postconf.5.html#undisclosed_recipients_header .
@mvdan yes it is different from ParseAddressList. ParseAddressList don't handle group https://play.golang.org/p/rhKTS4a2iG

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 26, 2017

Change https://golang.org/cl/66250 mentions this issue: net/mail: parse group in email address

@gopherbot gopherbot closed this in 6f2e5f9 Sep 27, 2017
@golang golang locked and limited conversation to collaborators Sep 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.