Reputation: 3405
I am using flask python to send emails using sendgrid, i followed the doc, where i install pip install sendgrid
and did the following, but the email is not sent and responds with a status code of 202, is there something i am missing
import sendgrid
from sendgrid.helpers.mail import Email, Content, Mail
def sendEmail():
try:
sg = sendgrid.SendGridAPIClient(apikey="hiddedAPIKey")
from_email = Email("[email protected]")
to_email = Email("[email protected]")
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)
except:
print("the was an error")
Upvotes: 0
Views: 1105
Reputation: 2334
Your emails must be going to spam. There are two ways to tackle this situation
sendgrid
official documentation to avoid emails to land into spam.Upvotes: 1