-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: remove leading spaces on error handling example (#1032)
- Loading branch information
1 parent
76c5f46
commit b729f40
Showing
1 changed file
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,24 +6,24 @@ Please see [here](https://github.com/sendgrid/python-http-client/blob/HEAD/pytho | |
There are also email specific exceptions located [here](../sendgrid/helpers/mail/exceptions.py) | ||
|
||
```python | ||
import os | ||
from sendgrid import SendGridAPIClient | ||
from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail) | ||
from python_http_client import exceptions | ||
import os | ||
from sendgrid import SendGridAPIClient | ||
from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail) | ||
from python_http_client import exceptions | ||
|
||
sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) | ||
from_email = From("[email protected]") | ||
to_email = To("[email protected]") | ||
subject = Subject("Sending with Twilio 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>") | ||
message = Mail(from_email, to_email, subject, plain_text_content, html_content) | ||
try: | ||
response = sendgrid_client.send(message) | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
except exceptions.BadRequestsError as e: | ||
print(e.body) | ||
exit() | ||
sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) | ||
from_email = From("[email protected]") | ||
to_email = To("[email protected]") | ||
subject = Subject("Sending with Twilio 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>") | ||
message = Mail(from_email, to_email, subject, plain_text_content, html_content) | ||
try: | ||
response = sendgrid_client.send(message) | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
except exceptions.BadRequestsError as e: | ||
print(e.body) | ||
exit() | ||
``` |