sendgrid / sendgrid-python

The Official Twilio SendGrid Python API Library
https://sendgrid.com
MIT License
1.55k stars 714 forks source link

Un-Authorize error(401) #894

Closed Aaris-Kazi closed 4 years ago

Aaris-Kazi commented 4 years ago

import os from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail

message = Mail( from_email='18co28@aiktc.ac.in', to_emails='aariskazi@gmail.com', subject='Sending with Twilio SendGrid is Fun', html_content='and easy to do anywhere, even with Python') try: sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) response = sg.send(message) print(response.status_code) print(response.body) print(response.headers) except Exception as e: print(e) output PS C:\Users\aaris\OneDrive\Desktop\python design\email> & C:/Users/aaris/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/aaris/OneDrive/Desktop/python design/email/mail6.py" HTTP Error 401: Unauthorized

why it is showing up to me