Created
July 3, 2019 18:57
-
-
Save bitsnaps/29136726499b574526380dc13ca6bc19 to your computer and use it in GitHub Desktop.
Send an email using sendinblue service api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sys import stderr | |
| import requests | |
| # make sure this example works | |
| # curl -s http://api.coindesk.com/v1/bpi/currentprice.json | python -c "import json, sys; print(json.load(sys.stdin)['bpi']['USD']['rate'])" | |
| def send_email(): | |
| resp = requests.post('https://api.sendinblue.com/v2.0/email', headers={'api-key':'YOUR_API_KEY'}, | |
| json={"to":{"[email protected]":"FULL NAME"}, "from":["[email protected]","Your Full Name"], "subject":"Your Solution","html":"Welcome to <h1>Solution</h1>"}) | |
| if resp: #.status_code==200: | |
| print(resp.json()) | |
| else: | |
| stderr.write(resp.json()['message']) | |
| pass | |
| if __name__=="__main__": | |
| send_email() | |
| print('done.') | |
| # more customization at: https://realpython.com/python-requests/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment