django-sendgrid-v5 icon indicating copy to clipboard operation
django-sendgrid-v5 copied to clipboard

commas in sender address names raise 400 error from sendgrid api

Open bharling opened this issue 4 years ago • 12 comments

Just hit this issue in production today unfortunately using this library, haven't had time to delve into it properly but will send a PR if I get the time

Steps to reproduce:

from dango.core.mail import send_mail
send_mail( "Subject", "Message", "Sender, Some Org <[email protected]>", ["[email protected]"])

{'status_code': 400, 'reason': 'Bad Request', 'body': b'{"errors":[{"message":"The from object must be provided for every email send. It is an object that requires the email parameter, but may also contain a name parameter.  e.g. {\\"email\\" : \\"[email protected]\\"}  or {\\"email\\" : \\"[email protected]\\", \\"name\\" : \\"Example Recipient\\"}.","field":"from.email","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.from"}]}', 'headers': <http.client.HTTPMessage object at 0x7fa2885b6198>}

I guess there is some parsing issue when converting smtp from_email addresses to the sendgrid sender object format?

bharling avatar Dec 18 '20 21:12 bharling

Yeah that looks like an API issue. Try sending some test emails using their API directly to repro the error and see what formatting you need to do to the emails in your database

On Dec 18, 2020, at 4:01 PM, Ben Harling [email protected] wrote:

 Just hit this issue in production today unfortunately using this library, haven't had time to delve into it properly but will send a PR if I get the time

Steps to reproduce:

from dango.core.mail import send_mail send_mail( "Subject", "Message", "Sender, Some Org [email protected]", ["[email protected]"])

{'status_code': 400, 'reason': 'Bad Request', 'body': b'{"errors":[{"message":"The from object must be provided for every email send. It is an object that requires the email parameter, but may also contain a name parameter. e.g. {\"email\" : \"[email protected]\"} or {\"email\" : \"[email protected]\", \"name\" : \"Example Recipient\"}.","field":"from.email","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.from"}]}', 'headers': <http.client.HTTPMessage object at 0x7fa2885b6198>} I guess there is some parsing issue when converting smtp from_email addresses to the sendgrid sender object format?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sklarsa avatar Dec 18 '20 21:12 sklarsa

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 17 '21 21:01 stale[bot]

Would like to reopen this if possible, sorry for delay in activity - also seeing issues if a user includes () in their name (I know this could be considered an edge case but shouldn't crash the library really). I'll try and implement a PR to fix both issues

bharling avatar Mar 09 '21 17:03 bharling

Maybe my stalebot duration needs to be adjusted too

sklarsa avatar Mar 09 '21 18:03 sklarsa

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 08 '21 19:04 stale[bot]

Any help for this issue

I am encountering the issue now

developertom01 avatar Dec 12 '21 22:12 developertom01

I'll take a look at the issue before the new year.. sorry for the delay

sklarsa avatar Dec 14 '21 14:12 sklarsa

Hey @sklarsa . Is there any update on this issue? Facing it right now. Need the from_email to support commas as they're part of the legal names to be used for some of the third parties and cannot be tweaked. If there's no solution yet, would really appreciate if anyone can help with a workaround which I can implement in the meanwhile. Thanks!

vedantidote avatar Mar 08 '22 19:03 vedantidote

Can you try to send a test email using sendgrid's python api outside of django (in a small script)? This way we can diagnose if it's an upstream issue or something specifically related to this repo...

sklarsa avatar Mar 08 '22 20:03 sklarsa

Is there any update on this? @bharling @sklarsa

alikr123 avatar Mar 21 '22 21:03 alikr123

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 19 '22 22:06 stale[bot]

Does anyone know where the issues went for the sendgrid-python package? I'm not sure how to open up an issue with Sendgrid, which I believe is the next step to debugging this issue.

I'm having trouble actually using the sendgrid website (to create an API token since I don't have a record of the one in the GitHub Actions), so can someone currently with API access check that sending an email with a bad character (,, ()) in the "From" string returns a 400?

sklarsa avatar Aug 17 '22 21:08 sklarsa

See https://github.com/sklarsa/django-sendgrid-v5/issues/117... I'd recommend using the official python api now

sklarsa avatar Jan 18 '23 21:01 sklarsa