Skip to content

Instantly share code, notes, and snippets.

@souravs17031999
Created August 19, 2021 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souravs17031999/c1d1bae39689464b5596a3e9281aa552 to your computer and use it in GitHub Desktop.
Save souravs17031999/c1d1bae39689464b5596a3e9281aa552 to your computer and use it in GitHub Desktop.
mail_body = generate_mail_content("mail.html)
message = Mail(
from_email=sender_email,
to_emails=receiver_email,
subject=subject,
html_content=mail_body)
try:
sendgridAPIClientKey = os.getenv('SENDGRID_API_KEY')
sg = SendGridAPIClient(sendgridAPIClientKey)
response = sg.send(message)
print(response.status_code)
except Exception as e:
print(e)
print(e.body)
print(e.message)
print("failure !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment