-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
2,289 additions
and
1,199 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins: | ||
pep8: | ||
enabled: true |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export SENDGRID_API_KEY='' |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines given above, then fill out the blanks below. | ||
|
||
|
||
Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! | ||
e.g. | ||
Fixes #1 | ||
Closes #2 | ||
--> | ||
# Fixes # | ||
|
||
### Checklist | ||
- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) | ||
- [ ] I have read the [Contribution Guide] and my PR follows them. | ||
- [ ] I updated my branch with the master branch. | ||
- [ ] I have added tests that prove my fix is effective or that my feature works | ||
- [ ] I have added necessary documentation about the functionality in the appropriate .md file | ||
- [ ] I have added in line documentation to the code I modified | ||
|
||
### Short description of what this PR does: | ||
- | ||
- | ||
|
||
If you have questions, please send an email to [Sendgrid](mailto:[email protected]), or file a Github Issue in this repository. |
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
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
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
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ This documentation provides examples for specific use cases. Please [open an iss | |
* [How to Setup a Domain Whitelabel](#domain_whitelabel) | ||
* [How to View Email Statistics](#email_stats) | ||
* [Asynchronous Mail Send](#asynchronous-mail-send) | ||
* [Error Handling](#error-handling) | ||
* [Deploy A Simple Hello Email App on AWS](#hello_email_on_aws) | ||
|
||
<a name="transactional-templates"></a> | ||
|
@@ -272,6 +273,35 @@ if __name__ == "__main__": | |
task = asyncio.async(send_many(ems, sample_cb)) | ||
loop.run_until_complete(task) | ||
``` | ||
|
||
<a name="error-handling"></a> | ||
# Error Handling | ||
[Custom exceptions](https://github.com/sendgrid/python-http-client/blob/master/python_http_client/exceptions.py) for `python_http_client` are now supported, which can be imported by consuming libraries. | ||
|
||
Please see [here](https://github.com/sendgrid/python-http-client/blob/master/python_http_client/exceptions.py) for a list of supported exceptions. | ||
|
||
```python | ||
import sendgrid | ||
import os | ||
from sendgrid.helpers.mail import * | ||
from python_http_client import exceptions | ||
|
||
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) | ||
from_email = Email("[email protected]") | ||
to_email = Email("[email protected]") | ||
subject = "Sending with SendGrid is Fun" | ||
content = Content("text/plain", "and easy to do anywhere, even with Python") | ||
mail = Mail(from_email, subject, to_email, content) | ||
try: | ||
response = sg.client.mail.send.post(request_body=mail.get()) | ||
except exceptions.BadRequestsError as e: | ||
print(e.body) | ||
exit() | ||
print(response.status_code) | ||
print(response.body) | ||
print(response.headers) | ||
``` | ||
|
||
<a name="hello_email_on_aws"></a> | ||
# Deploy a simple Hello Email app on AWS | ||
|
||
|
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
Oops, something went wrong.