summaryrefslogtreecommitdiffstats
path: root/examples/mail/mail.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mail/mail.js')
-rw-r--r--examples/mail/mail.js146
1 files changed, 73 insertions, 73 deletions
diff --git a/examples/mail/mail.js b/examples/mail/mail.js
index 009f10e..44af771 100644
--- a/examples/mail/mail.js
+++ b/examples/mail/mail.js
@@ -1,4 +1,4 @@
-var sg = require('../lib/sendgrid.js').SendGrid(process.env.SENDGRID_API_KEY)
+var sg = require('sendgrid-nodejs').SendGrid(process.env.SENDGRID_API_KEY)
///////////////////////////////////////////////////
// Create a batch ID
@@ -29,157 +29,157 @@ sg.API(request, function (response) {
})
///////////////////////////////////////////////////
-// v3 Mail Send Beta
-// POST /mail/send/beta
+// v3 Mail Send
+// POST /mail/send
-// This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-nodejs/blob/v3beta/lib/helpers/mail/README.md).
+// This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-nodejs/blob/master/lib/helpers/mail/README.md).
var request = sg.emptyRequest()
request.body = {
"asm": {
- "group_id": 1,
+ "group_id": 1,
"groups_to_display": [
- 1,
- 2,
+ 1,
+ 2,
3
]
- },
+ },
"attachments": [
{
- "content": "[BASE64 encoded content block here]",
- "content_id": "ii_139db99fdb5c3704",
- "disposition": "inline",
- "filename": "file1.jpg",
- "name": "file1",
+ "content": "[BASE64 encoded content block here]",
+ "content_id": "ii_139db99fdb5c3704",
+ "disposition": "inline",
+ "filename": "file1.jpg",
+ "name": "file1",
"type": "jpg"
}
- ],
- "batch_id": "[YOUR BATCH ID GOES HERE]",
+ ],
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
"categories": [
- "category1",
+ "category1",
"category2"
- ],
+ ],
"content": [
{
- "type": "text/html",
+ "type": "text/html",
"value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"from": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
- "headers": {},
- "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
+ },
+ "headers": {},
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
"mail_settings": {
"bcc": {
- "email": "ben.doe@example.com",
+ "email": "ben.doe@example.com",
"enable": true
- },
+ },
"bypass_list_management": {
"enable": true
- },
+ },
"footer": {
- "enable": true,
- "html": "<p>Thanks</br>The SendGrid Team</p>",
+ "enable": true,
+ "html": "<p>Thanks</br>The SendGrid Team</p>",
"text": "Thanks,/n The SendGrid Team"
- },
+ },
"sandbox_mode": {
"enable": false
- },
+ },
"spam_check": {
- "enable": true,
- "post_to_url": "http://example.com/compliance",
+ "enable": true,
+ "post_to_url": "http://example.com/compliance",
"threshold": 3
}
- },
+ },
"personalizations": [
{
"bcc": [
{
- "email": "sam.doe@example.com",
+ "email": "sam.doe@example.com",
"name": "Sam Doe"
}
- ],
+ ],
"cc": [
{
- "email": "jane.doe@example.com",
+ "email": "jane.doe@example.com",
"name": "Jane Doe"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"headers": {
- "X-Accept-Language": "en",
+ "X-Accept-Language": "en",
"X-Mailer": "MyApp"
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
"substitutions": {
"sub": {
"%name%": [
- "John",
- "Jane",
+ "John",
+ "Jane",
"Sam"
]
}
- },
+ },
"to": [
{
- "email": "john.doe@example.com",
+ "email": "john.doe@example.com",
"name": "John Doe"
}
]
}
- ],
+ ],
"reply_to": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
+ },
"sections": {
"section": {
- ":sectionName1": "section 1 text",
+ ":sectionName1": "section 1 text",
":sectionName2": "section 2 text"
}
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
- "template_id": "[YOUR TEMPLATE ID GOES HERE]",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
"tracking_settings": {
"click_tracking": {
- "enable": true,
+ "enable": true,
"enable_text": true
- },
+ },
"ganalytics": {
- "enable": true,
- "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
- "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
- "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
- "utm_name": "[NAME OF YOUR CAMPAIGN]",
+ "enable": true,
+ "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
+ "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
+ "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
+ "utm_name": "[NAME OF YOUR CAMPAIGN]",
"utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
- },
+ },
"open_tracking": {
- "enable": true,
+ "enable": true,
"substitution_tag": "%opentrack"
- },
+ },
"subscription_tracking": {
- "enable": true,
- "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
- "substitution_tag": "<%click here%>",
+ "enable": true,
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
+ "substitution_tag": "<%click here%>",
"text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
}
}
};
request.method = 'POST'
-request.path = '/v3/mail/send/beta'
+request.path = '/v3/mail/send'
sg.API(request, function (response) {
console.log(response.statusCode)
console.log(response.body)