How to send email in SENDGRID using Python

||
Posted 4 years, 7 months ago
||
Views 508
||
1 min read
0 reactions

Step 1:

pip install sendgrid

Step 2:

import sendgrid
import os
from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(apikey=[Your Sendgrid Key])
from_email = Email("")
to_email = Email("")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)


0 reactions

Discussion


Looking for Freelancing Jobs
Joined on April 15, 2020

Latest Videos