Skip to content
Browse files

Merge pull request #36 from sendgrid/upgrade-nodemailer-dependencies

Upgrade nodemailer dependencies and document tests
  • Loading branch information...
2 parents 1cc3b0c + 1324729 commit e7f9c1c62c37ee7b96afc11c0117ea1a6ad8f0db @brandonmwest brandonmwest committed Jun 22, 2012
Showing with 107 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 Makefile
  3. +20 −0 README.md
  4. +5 −3 index.js
  5. +15 −10 lib/sendgrid.js
  6. +64 −0 npm-shrinkwrap.json
  7. 0 test/{test.setup → config.sample.js}
  8. +1 −1 test/test_helper.js
View
1 .gitignore
@@ -1,3 +1,4 @@
node_modules/
npm-debug.log
.DS_Store
+test/config.js
View
2 Makefile
@@ -1,4 +1,4 @@
test:
- find test -name "*.test.js" | xargs mocha
+ ./node_modules/.bin/mocha test --recursive
.PHONY: test
View
20 README.md
@@ -11,6 +11,26 @@ Licensed under the MIT License.
npm install sendgrid
```
+## Testing ##
+
+In order to run the integration tests, you'll need to update the config file with your valid SendGrid credentials. Start by making a live copy of the sample:
+
+```
+cp test/config.sample.js test/config.js
+```
+
+Next, open up `test/config.js` and fill it in. After you have updated the configuration file with your credentials, you can run the suite using the following command:
+
+```
+make test
+```
+
+You can run individual tests with the following command:
+
+```
+./node_modules/.bin/mocha [path to test].js
+```
+
## Usage ##
### It can be this easy ###
View
8 index.js
@@ -1,3 +1,5 @@
-module.exports.SendGrid = require('./lib/sendgrid');
-module.exports.Email = require('./lib/email');
-module.exports.SmtpapiHeaders = require('./lib/smtpapi_headers');
+module.exports = {
+ SendGrid: require('./lib/sendgrid'),
+ Email: require('./lib/email'),
+ SmtpapiHeaders: require('./lib/smtpapi_headers')
+};
View
25 lib/sendgrid.js
@@ -110,20 +110,25 @@ SendGrid.prototype.send = function(email, callback) {
* @param {Function} callback A function to call when the processing is done.
*/
SendGrid.prototype.smtp = function(email, callback) {
- var self = this;
+ var self = this
+ , smtpTransport;
// SMTP settings
- nodemailer.SMTP = {
- host: 'smtp.sendgrid.net',
- use_authentication: true,
- ssl: true,
- user: this.api_user,
- pass: this.api_key
- };
+ smtpTransport = nodemailer.createTransport("SMTP", {
+ service: 'SendGrid',
+ auth: {
+ user: this.api_user,
+ pass: this.api_key
+ }
+ });
function send_smtp() {
- nodemailer.send_mail(email.toSmtpFormat(), function(error, success) {
- callback(success, error);
+ smtpTransport.sendMail(email.toSmtpFormat(), function(error, response) {
+ smtpTransport.close();
+ if(error) {
+ return callback(false, response);
+ }
+ return callback(true, response);
});
}
View
64 npm-shrinkwrap.json
@@ -0,0 +1,64 @@
+{
+ "name": "sendgrid",
+ "version": "0.2.2",
+ "dependencies": {
+ "underscore": {
+ "version": "1.3.3"
+ },
+ "nodemailer": {
+ "version": "0.3.20",
+ "dependencies": {
+ "mailcomposer": {
+ "version": "0.1.14",
+ "dependencies": {
+ "mimelib-noiconv": {
+ "version": "0.1.7"
+ }
+ }
+ },
+ "simplesmtp": {
+ "version": "0.1.18",
+ "dependencies": {
+ "rai": {
+ "version": "0.1.6"
+ }
+ }
+ }
+ }
+ },
+ "mime": {
+ "version": "1.2.5"
+ },
+ "step": {
+ "version": "0.0.5"
+ },
+ "chai": {
+ "version": "1.0.4"
+ },
+ "mocha": {
+ "version": "1.2.0",
+ "dependencies": {
+ "commander": {
+ "version": "0.5.2"
+ },
+ "growl": {
+ "version": "1.5.1"
+ },
+ "jade": {
+ "version": "0.20.3",
+ "dependencies": {
+ "mkdirp": {
+ "version": "0.3.3"
+ }
+ }
+ },
+ "diff": {
+ "version": "1.0.2"
+ },
+ "debug": {
+ "version": "0.7.0"
+ }
+ }
+ }
+ }
+}
View
0 test/test.setup → test/config.sample.js
File renamed without changes.
View
2 test/test_helper.js
@@ -1,2 +1,2 @@
global.expect = require('chai').expect;
-global.setup = require('./test.setup');
+global.setup = require('./config');

0 comments on commit e7f9c1c

Please sign in to comment.
Something went wrong with that request. Please try again.