Skip to content

Instantly share code, notes, and snippets.

@bitsnaps
Created July 3, 2019 18:57
Show Gist options
  • Select an option

  • Save bitsnaps/29136726499b574526380dc13ca6bc19 to your computer and use it in GitHub Desktop.

Select an option

Save bitsnaps/29136726499b574526380dc13ca6bc19 to your computer and use it in GitHub Desktop.
Send an email using sendinblue service api
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