python sending email with sendgrid code example

Example: 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='

My first mail using Sendgrid

' ) try: sg = SendGridAPIClient('') response = sg.send(message) print(response.status_code) print(response.body) print(response.headers) except Exception as e: #print(e.message) print(e)

Tags:

Misc Example