Closed glennzw closed 4 years ago
I think https://golang.org/pkg/net/mail/#ParseAddress might be what you’re looking for. :)
On May 22, 2020, at 12:23 PM, Glenn Wilkinson notifications@github.com wrote:
Is it possible to extract the sender name / email from an email object? I couldn't find an option for this in the documentation or code.
i.e from this:
e := &email.Email { From: "Jordan Wright test@gmail.com", } I'd like to extract "Jordan Wright" and "test@gmail.com" separately.
If not I'll just proceed with a regex, but wanted to check I wasn't missing something:
var r = regexp.MustCompile("^(.)<(.)>$") e := r.FindStringSubmatch(e.From) name := e[1] email := e[2] — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Whoops, right you are 🙈 Thanks!
Is it possible to extract the sender name / email from an email object? I couldn't find an option for this in the documentation or code.
i.e from this:
I'd like to extract "Jordan Wright" and "test@gmail.com" separately.
If not I'll just proceed with a regex, but wanted to check I wasn't missing something: