Skip to content

Inconsistent format of email from header “name <email>” #277

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

Closed
andriisoldatenko opened this issue Nov 29, 2016 · 2 comments
Closed
Labels
difficulty: medium fix is medium in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@andriisoldatenko
Copy link
Contributor

andriisoldatenko commented Nov 29, 2016

Issue Summary

Current implementation restrict use default email_from behavior. For more info please see https://tools.ietf.org/html/rfc2822#section-3.4

Steps to Reproduce

  1. When user try to create Email instance from https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/mail.py#L173-L179. You must specify
    from_email and from_name as seperate parametrs
    def get(self):
        email = {}
        if self.name != None:
            email["name"] = self.name
        if self.email != None:
            email["email"] = self.email
        return email

from_email = Email("[email protected]", "Example Name")

As a result client should split from_email:

try:
    import rfc822
except ImportError:
    import email.utils as rfc822


from_name, from_email = rfc822.parseaddr(email.from_email)
# Python sendgrid client should improve
# sendgrid/helpers/mail/mail.py:164
if not from_name:
    from_name = None
Mail(from_email, from_name)

Proposal to how to improve this bahaviour.
Because if user now create Email from:

from_email = Email("Andrii Soldatenko <[email protected]>")

Actual result:
image

Technical details:

  • sendgrid-python Version: master
  • Python Version: all

References:

NOTE:
In sengrid-python==1.4 this feature is working

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Nov 29, 2016
@thinkingserious
Copy link
Contributor

Nice work @andriisoldatenko!

I will add this to our backlog for an update. Thanks!

@mbernier
Copy link
Contributor

mbernier commented Oct 1, 2017

@andriisoldatenko I know it's been a minute since you submitted this, but I am curious if my change accomplishes your request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

3 participants