django-sendgrid-v5
django-sendgrid-v5 copied to clipboard
commas in sender address names raise 400 error from sendgrid api
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?
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.
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.
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
Maybe my stalebot duration needs to be adjusted too
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.
Any help for this issue
I am encountering the issue now
I'll take a look at the issue before the new year.. sorry for the delay
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!
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...
Is there any update on this? @bharling @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.
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?
See https://github.com/sklarsa/django-sendgrid-v5/issues/117... I'd recommend using the official python api now