sendgrid-python
sendgrid-python copied to clipboard
Able to send mail only one time, after it gives error 400
Issue Summary
I'm using this library to get users signup for my website, once they signup, they'll receive a mail. When I run the application, it works fine for first mail. But is not working for other mails if I signup again.
Code Snippet
def send_reset_email(user):
token = 'xyz'
mail.send_email(
from_email='[email protected]',
to_email= user.email,
subject='demo | Password reset link',
text= f"""
Dear User,
Thanks to be part of us!
Please follow below link in order to reset your account password:
{url_for('some_function', token=token, _external=True)}
This link will be expired in 20 minutes. If you did not make this request then simply ignore this email and no changes will be made.
"""
)
Exception/Log
python_http_client.exceptions.BadRequestsError: HTTP Error 400: Bad Request
Technical details:
- sendgrid-python version: 6.3.1
- python version: 3.8.2
Recommend catching the error and logging the response body to see the error details. Example here: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/error_handling.md