-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for Twilio Email #1093
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,27 +1,31 @@ | ||
This documentation provides examples for specific Twilio SendGrid v3 API use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-nodejs/issues) or make a pull request for any email use cases you would like us to document here. Thank you! | ||
|
||
# Email Use Cases | ||
* [Send a Single Email to a Single Recipient](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/single-email-single-recipient.md) | ||
* [Send a Single Email to Multiple Recipients](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/single-email-multiple-recipients.md) | ||
* [Send Multiple Emails to Multiple Recipients](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/multiple-emails-multiple-recipients.md) | ||
* [CC, BCC and Reply To](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/cc-bcc-reply-to.md) | ||
* [Flexible Email Address Fields](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/flexible-address-fields.md) | ||
* [Handling Success/Failure/Errors](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/success-failure-errors.md) | ||
* [Show Email Activity](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/email-activity.md) | ||
* [Advanced Usage](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/advanced.md) | ||
* [Transactional Templates](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/transactional-templates.md) | ||
* [Legacy Transactional Templates](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/transactional-legacy-templates.md) | ||
* [Hide Warnings](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/hide-warnings.md) | ||
* [Attachments](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/attachments.md) | ||
* [Customization Per Recipient](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/customization.md) | ||
* [Manually Providing Content](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/manual-content.md) | ||
* [Specifying Time to Send At](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/time-to-send.md) | ||
* [Specifying Custom Headers](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/custom-headers.md) | ||
* [Specifying Categories](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/categories.md) | ||
* [Timeout](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/timeout.md) | ||
* [Kitchen Sink - an example with all settings used](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/kitchen-sink.md) | ||
* [Send a Single Email to a Single Recipient](single-email-single-recipient.md) | ||
* [Send a Single Email to Multiple Recipients](single-email-multiple-recipients.md) | ||
* [Send Multiple Emails to Multiple Recipients](multiple-emails-multiple-recipients.md) | ||
* [CC, BCC and Reply To](cc-bcc-reply-to.md) | ||
* [Flexible Email Address Fields](flexible-address-fields.md) | ||
* [Handling Success/Failure/Errors](success-failure-errors.md) | ||
* [Show Email Activity](email-activity.md) | ||
* [Advanced Usage](advanced.md) | ||
* [Transactional Templates](transactional-templates.md) | ||
* [Legacy Transactional Templates](transactional-legacy-templates.md) | ||
* [Hide Warnings](hide-warnings.md) | ||
* [Attachments](attachments.md) | ||
* [Customization Per Recipient](customization.md) | ||
* [Manually Providing Content](manual-content.md) | ||
* [Specifying Time to Send At](time-to-send.md) | ||
* [Specifying Custom Headers](custom-headers.md) | ||
* [Specifying Categories](categories.md) | ||
* [Timeout](timeout.md) | ||
* [Kitchen Sink - an example with all settings used](kitchen-sink.md) | ||
|
||
# Twilio Use Cases | ||
* [Twilio Setup](twilio-setup.md) | ||
* [Send an Email With Twilio Email (Pilot)](twilio-email.md) | ||
* [Send an SMS Message](sms.md) | ||
|
||
# Non-Email Use Cases | ||
* [Send a SMS Message](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/sms.md) | ||
* [How to Setup a Domain Whitelabel](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/domain-white-label.md) | ||
* [How to View Email Statistics](https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/email-stats.md) | ||
* [How to Set up a Domain Whitelabel](domain-white-label.md) | ||
* [How to View Email Statistics](email-stats.md) |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
First, follow the [Twilio Setup](twilio-setup.md) guide for creating a Twilio account and setting up environment variables with the proper credentials. | ||
|
||
Then, initialize the Twilio Email Client. | ||
|
||
```js | ||
const client = require('@sendgrid/client'); | ||
|
||
client.setTwilioEmailAuth(process.env.TWILIO_API_KEY, process.env.TWILIO_API_SECRET); | ||
|
||
// or | ||
|
||
client.setTwilioEmailAuth(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN); | ||
``` | ||
|
||
Or similarly using the mail helper. | ||
|
||
```js | ||
const mail = require('@sendgrid/mail'); | ||
|
||
mail.setTwilioEmailAuth(process.env.TWILIO_API_KEY, process.env.TWILIO_API_SECRET); | ||
|
||
// or | ||
|
||
mail.setTwilioEmailAuth(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN); | ||
``` | ||
|
||
This sets the client to use Twilio Auth and the Twilio Email API. |
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,54 @@ | ||
## 1. Obtain a Free Twilio Account | ||
|
||
Sign up for a free Twilio account [here](https://www.twilio.com/try-twilio?source=sendgrid-nodejs). | ||
|
||
## 2. Set Up Your Environment Variables | ||
|
||
The Twilio API allows for authentication using with either an API key/secret or your Account SID/Auth Token. You can create an API key [here](https://twil.io/get-api-key) or obtain your Account SID and Auth Token [here](https://twil.io/console). | ||
|
||
Once you have those, follow the steps below based on your operating system. | ||
|
||
### Linux/Mac | ||
|
||
```bash | ||
echo "export TWILIO_API_KEY='YOUR_TWILIO_API_KEY'" > twilio.env | ||
echo "export TWILIO_API_SECRET='YOUR_TWILIO_API_SECRET'" >> twilio.env | ||
|
||
# or | ||
|
||
echo "export TWILIO_ACCOUNT_SID='YOUR_TWILIO_ACCOUNT_SID'" > twilio.env | ||
echo "export TWILIO_AUTH_TOKEN='YOUR_TWILIO_AUTH_TOKEN'" >> twilio.env | ||
``` | ||
|
||
Then: | ||
|
||
```bash | ||
echo "twilio.env" >> .gitignore | ||
source ./twilio.env | ||
``` | ||
|
||
### Windows | ||
|
||
Temporarily set the environment variable (accessible only during the current CLI session): | ||
|
||
```bash | ||
set TWILIO_API_KEY=YOUR_TWILIO_API_KEY | ||
set TWILIO_API_SECRET=YOUR_TWILIO_API_SECRET | ||
|
||
: or | ||
|
||
set TWILIO_ACCOUNT_SID=YOUR_TWILIO_ACCOUNT_SID | ||
set TWILIO_AUTH_TOKEN=YOUR_TWILIO_AUTH_TOKEN | ||
``` | ||
|
||
Or permanently set the environment variable (accessible in all subsequent CLI sessions): | ||
|
||
```bash | ||
setx TWILIO_API_KEY "YOUR_TWILIO_API_KEY" | ||
setx TWILIO_API_SECRET "YOUR_TWILIO_API_SECRET" | ||
|
||
: or | ||
|
||
setx TWILIO_ACCOUNT_SID "YOUR_TWILIO_ACCOUNT_SID" | ||
setx TWILIO_AUTH_TOKEN "YOUR_TWILIO_AUTH_TOKEN" | ||
``` |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice