Permalink
Browse files

Version bump 0.3.0-rc.1.3 - add ability to change port to 465 and sen…

…d over ssl. 587 still recommended because some hosts rate limit 465.
  • Loading branch information...
1 parent d419992 commit 64e2af96293c9b9c0d2c7bbaee8dfeeb1f3d21a7 @motdotla motdotla committed Aug 15, 2013
Showing with 32 additions and 6 deletions.
  1. +11 −3 lib/sendgrid.js
  2. +1 −1 npm-shrinkwrap.json
  3. +1 −1 package.json
  4. +12 −0 test/integration/sendgrid.test.js
  5. +7 −1 test/lib/sendgrid.test.js
View
@@ -95,13 +95,20 @@ module.exports = function(api_user, api_key) {
var _sendSmtp = function(email, callback) {
// SMTP settings
- var smtpTransport = nodemailer.createTransport(self.SMTP, {
- service: 'SendGrid',
+ var smtp_settings = {
+ host: "smtp.sendgrid.net",
+ port: parseInt(self.port),
+ requiresAuth: true,
auth: {
user: api_user,
pass: api_key
}
- });
+ }
+ if (smtp_settings.port == 465) {
+ smtp_settings['secureConnection'] = true;
+ }
+
+ var smtpTransport = nodemailer.createTransport(self.SMTP, smtp_settings);
smtpTransport.sendMail(email.toSmtpFormat(), function(error, response) {
smtpTransport.close();
@@ -117,6 +124,7 @@ module.exports = function(api_user, api_key) {
*/
return {
version : package_json.version,
+ port : 587,
SMTP : "SMTP",
Email : Email,
SmtpapiHeaders : SmtpapiHeaders,
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -9,7 +9,7 @@
],
"name": "sendgrid",
"description": "A NodeJS implementation of the SendGrid Api.",
- "version": "0.3.0-rc.1.2",
+ "version": "0.3.0-rc.1.3",
"homepage": "http://sendgrid.com",
"repository": {
"type": "git",
@@ -419,6 +419,18 @@ describe('SendGrid #skip', function () {
});
});
+ it('sends successfully over port 465', function(done) {
+ payload.subject += "sends successfully over port 465";
+
+ sendgrid.port = 465;
+ sendgrid.smtp(payload, function(err, json) {
+ expect(err).to.be.null;
+ expect(json.message).to.equal('success');
+
+ done();
+ });
+ });
+
it('has array of TOs', function(done) {
payload.subject += "has array of TOs";
payload.to = [process.env.TO]
@@ -19,7 +19,13 @@ describe('SendGrid', function () {
});
it('version should be set', function() {
- expect(sendgrid.version).to.equal("0.3.0-rc.1.2");
+ expect(sendgrid.version).to.equal("0.3.0-rc.1.3");
+ });
+
+ it('SMTP_PORT should be set and settable', function() {
+ expect(sendgrid.port).to.equal(587);
+ sendgrid.port = 465;
+ expect(sendgrid.port).to.equal(465);
});
describe('#send', function() {

0 comments on commit 64e2af9

Please sign in to comment.