-
Notifications
You must be signed in to change notification settings - Fork 8
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
5 changed files
with
64 additions
and
0 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 |
---|---|---|
|
@@ -35,3 +35,4 @@ jspm_packages | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
sendgrid.env |
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,29 @@ | ||
var kue = require('kue') | ||
var queue = kue.createQueue() | ||
require('dotenv').config() | ||
|
||
queue.process('email', function (job, done) { | ||
var helper = require('sendgrid').mail | ||
console.log(job.data) | ||
var from_email = new helper.Email(job.data.from) | ||
var to_email = new helper.Email(job.data.to) | ||
var subject = job.data.subject | ||
var content = new helper.Content('text/plain', job.data.text) | ||
var mail = new helper.Mail(from_email, subject, to_email, content) | ||
|
||
console.log(process.env.SENDGRID_API_KEY) | ||
var sg = require('sendgrid')('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' | ||
) | ||
var request = sg.emptyRequest({ | ||
method: 'POST', | ||
path: '/v3/mail/send', | ||
body: mail.toJSON() | ||
}) | ||
|
||
sg.API(request, function (error, response) { | ||
console.log(response.statusCode) | ||
console.log(response.body) | ||
console.log(response.headers) | ||
done() | ||
}) | ||
}) |
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,11 @@ | ||
var kue = require('kue') | ||
var queue = kue.createQueue() | ||
|
||
var data = { | ||
from: 'Dokobot <[email protected]>', | ||
to: '[email protected]', | ||
subject: 'Hello World from the SendGrid Node.js Library! oke oke', | ||
text: 'Testing some Mailgun awesomness.. Ahooyyy!' | ||
} | ||
|
||
var nitip = queue.create('email', data).save() |
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,23 @@ | ||
{ | ||
"name": "its-background-job", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/darwins-fox-2017/its-background-job.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/darwins-fox-2017/its-background-job/issues" | ||
}, | ||
"homepage": "https://github.com/darwins-fox-2017/its-background-job#readme", | ||
"dependencies": { | ||
"dotenv": "^4.0.0", | ||
"sendgrid": "^4.8.2" | ||
} | ||
} |