Inspiration

LHD BUILD 2021

What it does

Sends an e-mail

How we built it

Python and sendgrid api

Steps

Step 1 : Install sendgrid library

pip install sendgrid

STEP2 : Get API Keys from sendgrid

STEP3 : type the following code in ur text editor

{
import os
import json
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail, From, To, Subject, PlainTextContent, HtmlContent, SendGridException

message = Mail(from_email=From('[email protected]', 'Twilio SendGrid'),
               to_emails=To('[email protected]', 'xyz'),
               subject=Subject('Sending with SendGrid is Fun'),
               plain_text_content=PlainTextContent('and easy to do anywhere, even with Python'),
               html_content=HtmlContent('<strong>and easy to do anywhere, even with Python</strong>'))

try:
    print(json.dumps(message.get(), sort_keys=True, indent=4))
    sendgrid_client = SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))
    response = sendgrid_client.send(message=message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except SendGridException as e:
    print(e.message)
}

STEP 4 : Run the .py file

Built With

Share this project:

Updates

Submission history