python sending email with sendgrid
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import (Mail, Attachment, FileContent, FileName, FileType, Disposition)
message = Mail(
from_email='[email protected]',
to_emails='[email protected]',
subject='Sending email with Sengrid',
html_content='<p>My first mail using Sendgrid</p>'
)
try:
sg = SendGridAPIClient('<SENDGRID_API_KEY>')
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
#print(e.message)
print(e)