Basic Usage of sendGrid API using python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
print('Enter Subject for message')
subject = input()
message = Mail(
from_email='ayushjain2205@gmail.com',
to_emails='ayushjain2205@gmail.com',
subject=subject,
html_content='<strong>This message is sent from sendGrid using python!!</strong>')
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(e.message)
Log in or sign up for Devpost to join the conversation.