Giter VIP home page Giter VIP logo

sendgrid-nodejs's Introduction

Twilio SendGrid Logo

BuildStatus npm version Twitter Follow GitHub contributors MIT licensed Open Source Helpers

Twilio SendGrid Docs

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Node.js.

We want this library to be community-driven, and Twilio SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or merely upvote or comment on existing issues or pull requests.

For updates to this library, see our CHANGELOG and releases.

If you need support using Sendgrid, please check the Twilio SendGrid Support Help Center.

Table of Contents

Introduction - Please Read First

This library is broken up into several packages as a monorepo so that you only need to install the packages necessary for your use case. This README contains information about all packages. For examples on how to get started quickly, head over to the READMEs of each package (linked and described below), which includes detailed examples.

Announcements

BREAKING CHANGE: Please see the Twilio SendGrid Node.js Migration Guide 6.X.X -> 7.X.X for details.

All updates to this library are documented in our CHANGELOG and releases.

How to Contribute

We encourage contribution to our libraries (you might even score some nifty swag), please see our CONTRIBUTING guide for details.

Troubleshooting

Please see our troubleshooting guide for common library issues.

About

sendgrid-nodejs is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-nodejs are trademarks of Twilio SendGrid, Inc.

Support

If you need help using SendGrid, please check the Twilio SendGrid Support Help Center.

License

The MIT License (MIT)

sendgrid-nodejs's People

Contributors

adamreisnz avatar alanunruh avatar aroach avatar aslafy-z avatar bpneal avatar brandonmwest avatar dependabot[bot] avatar devchas avatar eddiezane avatar eshanholtz avatar jamsinclair avatar jennifermah avatar mbernier avatar motdotla avatar mptap avatar nitish24p avatar notheotherben avatar nquinlan avatar partkyle avatar peterkuiper avatar shwetha-manvinkurke avatar sigv avatar siyegen avatar theycallmeswift avatar thinkingserious avatar tony-ho avatar tushdante avatar twilio-ci avatar twilio-dx avatar uniopifex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sendgrid-nodejs's Issues

Using array in bcc does not work

Bcc in payload do work while using string as bcc ( bcc to one person ).

But while using array ( bcc to many people ), it doesn't work.

I have printed out the request form, and found that it did not append bcc content in POST payload while using array.

Sending Scheduled Emails

I am wondering if it's possible to send scheduled emails using this library.
I have looked through the docs, but haven't seen anything like that.

Package name incorrect in example

In your README example, you require 'sendgrid'. In practice, your package.json indicates that you need to require 'sendgrid-nodejs'

API_key

Hey,

how can I create my api key ?

errors: Unexpected token <

We are continuing to intermittently get these errors in our production environment, which means in these cases our customers are not getting their emails. After the fix to #94 it no longer crashes our server, but there is some underlying issue with the sendgrid service that needs to get addressed.

As an intermediate step (and the reason i'm filing this here), it would be very helpful in this library surfaced the raw API response too in the case of an error like this, so we could see what is going on.

here is the top of the stack trace (we are using [email protected]):

Error: SyntaxError: Unexpected token <\n at Request._callback (/app/node_modules/sendgrid/lib/sendgrid.js:89:25)\n at Request.init.self.callback (/app/node_modules/sendgrid/node_modules/request/index.js:148:22)\n at Request.EventEmitter.emit (events.js:99:17)\n at Request.onResponse (/app/node_modules/sendgrid/node_modules/request/index.js:886:14)\n at Request.EventEmitter.emit (events.js:126:20)\n at IncomingMessage.Request.onResponse.buffer (/app/node_modules/sendgrid/node_modules/request/index.js:837:12)\n

Sending to array of email addresses broke

I've been sending emails to an array of email addresses for some time. A few days ago it just broke for me. I now get this response:
false [ 'Missing destination email' ]

If I send it to a single email address in a string it works.

Can you please confirm this problem and respond with an ETA of a fix?

My options JSON looks like this:
var params = {
to: ['[email protected]'],
from: ['[email protected]'],
subject: "subject",
html: "test body"
};

npm install error

npm install sendgrid raises errors on Mac OS X Mountain Lion:

npm http GET https://registry.npmjs.org/sendgrid
npm http 304 https://registry.npmjs.org/sendgrid
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/nodemailer
npm http 304 https://registry.npmjs.org/underscore
npm ERR! Error: No compatible version found: underscore@'[email protected]'
npm ERR! Valid install targets:
npm ERR! ["1.0.3","1.0.4","1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","1.3.0","1.3.1","1.3.2","1.3.3","1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.5.0","1.5.1"]
npm ERR! at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:553:10)
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:477:15
npm ERR! at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:220:7
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Darwin 12.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "sendgrid" "--save"
npm ERR! cwd /Users/M/Documents/Zenvestment/Program/website
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.59
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/nodemailer
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/M/Documents/Zenvestment/Program/website/npm-debug.log
npm ERR! not ok code 0

Refactor tests to not send actual requests

There is really no need for us to send out actual requests in the tests. In the current format, you would have to manually open and check somewhere in the neighborhood of 40 emails. We can eliminate a lot of this overhead by mocking out the server and checking that the requests are made and in the format that SendGrid expects us to have.

This is labeled as urgent because the TravisCI build is broken until it is fixed and it's blocking a number of pending pull requests.

fromname & setFromName not working

I'm trying to set the canonical names of email sender, I tried with new Email ({ fromname: 'XXX' }); and email.setFromName('XXX'), but my emails are still only showing the email of the sender, not the name.

Can you provide a sample of how I can achieve this? Thanks!

HPE_INVALID_CONSTANT error

Hi, I'm using the old sendgrid-nodejs library (< 0.3.0) and I'm occasionally getting an error with the message {"bytesParsed":187,"code":"HPE_INVALID_CONSTANT"}.

Any hints on what this means in the context of SendGrid? Did you fix anything for this in 0.3.0?

Update answers for using library throughout the internet

Because version 0.3.x is coming out, @nquinlan made a good point that we need to update the answers throughout the internet. This will mainly fall to me, but anyone outside or inside SendGrid is welcome to jump in as well.

I'll start maintaining a list to get ready for the official 0.3.0 release.

Sites likely effected:

  • Stack Overflow
  • Quora
  • SendGrid Zendesk
  • Get Satisfaction
  • Old Blog posts
  • Google searches

Supply nodemailer options when sending via smtp

Hey @scottmotte,

I'm going to submit a pull request that allows for more options to be passed through to nodemailer for sending via smtp. I plan to add it as a third optional param (ordered before the callback though) on the sendgrid.smtp method.

Specifically for now I want to pass a messageId, and will be using it for references and inReplyTo as well - but I'll make sure the implementation is generic and can take an object, and passes any fields through. https://github.com/andris9/Nodemailer#e-mail-message-fields

I haven't implemented it yet - I thought I'd discuss it first to see if you'd have an opinion on a different way to implement it, or even if it's something you might not be will to pull in.

My primary goal is to allow the messageId to be set.

Tim.

1.2.0 still pulls [email protected]

when using npm install sendgrid I still get request 2.22.0 rather then 2.40.0. Then npm list gives me:

├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected] invalid

It looks like @nquinlan updated npm-shrinkwrap.json after the 1.2.0 bump, so I recommend bumping the version again (1.2.1?) to fix this issue and let sendgrid get updated dependencies.

full output:

use standard callback pattern

why is the callback pattern cb(success, msg) when the standard node.js callback pattern used virtually everywhere is cb(error, success)?

TypeError: Object # has no method 'toJsonString'

From GetSatisfaction:http://community.sendgrid.com/sendgrid/topics/typeerror_object_has_no_method_tojsonstring

I'm using the sendgrid node module. My coworker's machine runs everything fine. All our files are the same as we use git for version control. We have both done npm update: current version of sendgrid module is 1.0.0-rc.1.0. I also sometimes get a 'wrong credentials' error with this error, the credentials are correct so that is a false error.

Stack trace: 
TypeError: Object # has no method 'toJsonString' 
at Email.toWebFormat (/project/node_modules/sendgrid/lib/email.js:131:32) 
at _send (/project/node_modules/sendgrid/lib/sendgrid.js:67:31) 
at send (/project/node_modules/sendgrid/lib/sendgrid.js:31:21) 
at Object.exports.sendVerifyEmail (/project/utilities/emailer.js:16:11) 
at exports.email (/project/routes/index.js:156:43) 
at callbacks (/project/node_modules/express/lib/router/index.js:164:37) 
at param (/project/node_modules/express/lib/router/index.js:138:11) 
at param (/project/node_modules/express/lib/router/index.js:135:11) 
at pass (/project/node_modules/express/lib/router/index.js:145:5) 
at Router._dispatch (/project/node_modules/express/lib/router/index.js:173:5)

This may better be attached to sendgrid/smtpapi-nodejs. @scottmotte please advise.

crash in sendgrid module due to parsing bad response

We had a production crash last night in the sendgrid module. At line 83 in sendgrid.js, there is a call JSON.parse(body);. This threw an exception because apparently the sendgrid service must have sent an unexpected response. calls to JSON.parse should always be wrapped in a try/catch to handle this sort of case.

Here was the stack at the crash:

undefined:1
<html>
^
SyntaxError: Unexpected token <
    at Object.parse (native)
    at Request._callback (/app/node_modules/sendgrid/lib/sendgrid.js:83:23)
    at Request.init.self.callback (/app/node_modules/sendgrid/node_modules/request/index.js:148:22)
    at Request.EventEmitter.emit (events.js:99:17)
    at Request.onResponse (/app/node_modules/sendgrid/node_modules/request/index.js:886:14)
    at Request.EventEmitter.emit (events.js:126:20)
    at IncomingMessage.Request.onResponse.buffer (/app/node_modules/sendgrid/node_modules/request/index.js:837:12)
    at IncomingMessage.Proxy.callback.args.(anonymous function) (/app/node_modules/nodetime/lib/core/proxy.js:131:20)
    at IncomingMessage.EventEmitter.emit (events.js:126:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1485:20)
    at CleartextStream.CryptoStream._push (tls.js:544:27)
    at SecurePair.cycle (tls.js:898:20)
    at EncryptedStream.CryptoStream.write (tls.js:285:13)
    at Socket.ondata (stream.js:38:26)
    at Socket.EventEmitter.emit (events.js:96:17)
    at TCP.onread (net.js:397:14) EXCEPT

Can't install `smtpapi@'[email protected]'`

Seems there is an issue with a dep. I am using Node 0.8.14, which should be supported according to the package.json.

> npm i sendgrid --save
npm WARN package.json [email protected] No README.md file found!
npm http GET https://registry.npmjs.org/sendgrid
npm http 200 https://registry.npmjs.org/sendgrid
npm http GET https://registry.npmjs.org/sendgrid/-/sendgrid-1.0.3.tgz
npm http 200 https://registry.npmjs.org/sendgrid/-/sendgrid-1.0.3.tgz
npm http GET https://registry.npmjs.org/smtpapi
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/lodash
npm http 200 https://registry.npmjs.org/smtpapi
npm ERR! Error: No compatible version found: smtpapi@'[email protected]'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2"]
npm ERR!     at installTargetsError (/Users/neo/.nvm/v0.8.14/lib/node_modules/npm/lib/cache.js:563:10)
npm ERR!     at /Users/neo/.nvm/v0.8.14/lib/node_modules/npm/lib/cache.js:478:10
npm ERR!     at saved (/Users/neo/.nvm/v0.8.14/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at /Users/neo/.nvm/v0.8.14/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:218:7
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 13.1.0
npm ERR! command "/Users/neo/.nvm/v0.8.14/bin/node" "/Users/neo/.nvm/v0.8.14/bin/npm" "i" "sendgrid" "--save"
npm ERR! cwd /Users/neo/projects/Modulus/trek
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm http 200 https://registry.npmjs.org/mime
npm http 200 https://registry.npmjs.org/lodash
npm http 200 https://registry.npmjs.org/request
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/neo/projects/Modulus/trek/npm-debug.log
npm ERR! not ok code 0

templating to send bulk emails

How do I send bulk email from my node.js application to my users. now a days I am using "sendgrid-mustache" to send emails to my users, because in that library I am able to give single template and list of emails, Here this fetcher is missing. and How can we get individual emails status from sendgrid? means If I am sending 100 emails at a time, I want sendgrid status (e.g. pending, sent, bounced, spam) for each email. can this is possible?
If I am send single email at a time (run loop on my all emails, and send single at a time), what is the performance issue?

thanks

Custom sender description

Is there a way to configure options so that the recipient's email client will display a "custom" decription of the sender name instead of the regular email address?

To see what I mean please have a look at the top example here:

var mailOptions = {
    from: 'Fred Foo ✔ <[email protected]>', // sender address
    to: '[email protected], [email protected]', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world ✔', // plaintext body
    html: '<b>Hello world ✔</b>' // html body
};

In this case the recipient should see "Fred Foo", and not "[email protected]". Is this supported by the SendGrid API, and how should it be configured?

Thanks!

Incorrect code in sample documentation

The sample on substitutions is wrong. Should be addSubstitition

var email     = new sendgrid.Email();
email.setSubstitutions('keep', 'secret'); // sub = {keep: ['secret']}
email.addSubstitution('other', ['one', 'two']); 

PS: Please remove the references to Arsenal and football. It's cringeworthy.

Bcc not working?

Using sendgrid on Azure, adding the bcc like this:

function createEmail(mail, recips, bcc, sig, callback) {
var newemail = new Email({
to: recips[0],
bcc: bcc[0],
from: mail.FromAddress,
subject: mail.Subject,
html: mail.Details
});

for(var s in recips){                    
    if(s !== 0){
        newemail.addTo(recips[s]);
    }
}

newemail.addFilterSetting('footer', 'enable', 1);
newemail.addFilterSetting('footer', 'text/html', sig);

callback(newemail);  

}

It's not working...

NPM Install SENDGRID Error on SmartOS

-bash-4.1$ npm -version
0.3.18
-bash-4.1$ npm update -g
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info outdated Everything up-to-date.
npm info update Nothing to update
npm ok
-bash-4.1$ npm install sendgrid
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/sendgrid/-/sendgrid-0.2.7.tgz
npm info calculating sha1 /tmp/npm-1366127033448/1366127033448-0.21733342506922781/tmp.tgz
npm info shasum 9e26f68517d0242f39aa7c72673b7d118d17800c
npm ERR! Error installing [email protected]
npm ERR! Error: Empty package tarball
npm ERR! at /opt/local/lib/node/.npm/npm/0.3.18/package/lib/cache.js:377:37
npm ERR! at cb (/opt/local/lib/node/.npm/npm/0.3.18/package/lib/utils/graceful-fs.js:31:9)
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm ERR! System SunOS 5.11
npm ERR! argv { remain: [ 'sendgrid' ],
npm ERR! argv cooked: [ 'install', 'sendgrid' ],
npm ERR! argv original: [ 'install', 'sendgrid' ] }
npm not ok

smtp api bump up causes versioning issue

when you bumped the version to 1.0.4 - the subsequent smtp api got bumped as well - which has a different response header.

I am using sendgrid 1.0.2 and my smptapi response changed from

smtpapi: 
   { to: [ '[email protected]' ],
     sub: {},
     unique_args: {},
     category: [],
     section: {},
     filters: {} },

to

smtpapi: 
   { version: '1.0.2',
     header: 
      { to: [Object],
        sub: {},
        unique_args: {},
        category: [],
        section: {},
        filters: {} } },

can you add versioning to your npm ? so i can still grab the 1.0.2 version?

thanks!

Blank request sends malformed post data string

If you send out a request using .send with a blank object in it, you get the following malformed post data string:

api_user=some_sendgrid_username&api_key=some_sendgrid_password&&from=&x-smtpapi=%7B%7D&subject=&text=&html=&&replyto=&headers=%7B%7D

Source: sendgrid.send({});

Sender Name is not set when sending email via SMTP

Consider the following code:

var sendgrid = require("sendgrid")(sg_username, sg_password);
var Email = sendgrid.Email;
var email = new Email({
    to:        '[email protected]',
    from:       '[email protected]',
    fromname:   'This is my name',
    subject:    'Test subject',
    text:       'Test text',
    html:       '<h1>Test HTML Body</h1>'
});
sendgrid.send(email, function(err, json) {
    if (err) return console.log(err);
    console.log(json);
});

This will produce correct results, and you will receive correct From email header:
From: This is my name <[email protected]>

By selecting to send email via SMTP:

var sendgrid  = require("sendgrid")(sg_username, sg_password, {api: 'smtp'});

the from name is missing.
From: <[email protected]>

TypeError: Object #<Header> has no method 'toJsonString'

I just re-installed all of my modules from dependencies and sendgrid is now throwing errors. Not sure why is that?

(function() {
    var config = require('./config')()
        , sendgrid = require('sendgrid')(config.sendgrid.username, config.sendgrid.password)
        , email;
// Also tried: sendgrid = require('sendgrid')(config.sendgrid.username, config.sendgrid.password, {api: config.sendgrid.api})

    sendgrid.send({
        to:       '[email protected]',
        from:     '[email protected]',
        subject:  'Account Activation',
        text:     'Banana Song?'
    }, function(err, msg) {
        console.log(arguments);
    })
})();

but everytime it throws:

TypeError: Object #<Header> has no method 'toJsonString'

Before digging, I thought to post the issue if that's already fixed or in pipe! Thanks!

Shrinkwrap dependencies not working with Node 0.8

In your npm shrinkwrap file you are referencing mocha at version 1.2.0, which is not compatible with node 0.8. Newer versions of mocha work fine. Your shrinkwrap also contains outdated version information about your own package (0.2.2 instead of 0.2.3).

Do you really need the shrinkwrap at all? Why is the package.json not sufficient in your case?

Not sent to bcc

Hi, i had a little problem to send an email with bcc

I try the simplest code :

var sendgrid = require('sendgrid')("KEY", "SECRET");

sendgrid.send({
    to: [ '[email protected]' ],
    bcc: [ '[email protected]' ],
    from: '[email protected]',
    subject: 'my subjet',
    html: '<h1>hello</h1>',
    text: 'hello'
}, function (err, ret) {
    res.json({err: err, ret: ret});
})

Email is correctly sent to [email protected] but not to [email protected]

Return is

{
    "err": null,
    "ret": {
        "message": "success"
    }
}

Request: Add a changelog or history file please?

Hey Scott,

You're doing an awesome job maintaining this. Great to see your responsiveness in action.

Unless there's some form of this already, I'd love for a history or changelog file to be added to make it easy to see a summary of changes between versions. Is this something you'd be willing to do?

Thanks again.

File attachment is empty/broken.

Although I have verified that the file does exist and is accessible, the email that is sent attaches an empty file. I have tried 3 different ways to attach the file, all that return success from the send json response. The code I'm currently using is as follows. The rk object is simply a namespace.

        console.log(call.recording);
        var email = new rk.sendgrid.Email({
          to: '[email protected]',
          from: rk.config.email_address,
          subject: 'RoadKid Feedback',
          text: 'Someone left feedback on your driver.'//,
          //files: [
          //  {
          //    contentType: 'audio/mpeg',
          //    url: call.recording
          //  }
          //]
        });

        email.addFile({
          filename: 'feedback.mp3',
          contentType: 'audio/mpeg',
          url: call.recording
        });

        rk.sendgrid.send(email, function(err, json) {
          if (err) { return console.error(err); }
          console.log(json);
        });

An example url value is:

http://api.twilio.com/2010-04-01/Accounts/AC4a36110ce12a9cd68a947c87a3a6ab36/Recordings/RE568ecf17e4960105cd131507d49e182f.mp3

Improve Error Reporting for timeout issues

When Sendgrid's SMTP server has timeout issues (as at does at the time of logging this), the error reporting is poor. The error message appears to be blank, instead of giving some description of what the problem is.

I'm not sure if this is a problem with the sendgrid module, mailcomposer, or simplesmtp.

This can be reproduced by turning your wifi network off and then trying to send a message locally.

Sample:

error.name Error
error.message
error.stack Error
at MailComposer.module.exports._sendSmtp as returnCallback
at SMTPConnectionPool._onConnectionError (.npm/package/node_modules/sendgrid/node_modules/nodemailer/node_modules/simplesmtp/lib/pool.js:295:17)
at SMTPClient.EventEmitter.emit (events.js:96:17)
at SMTPClient._onError (.npm/package/node_modules/sendgrid/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:303:10)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket.connect.require.lookup.addressType (net.js:699:16)
at process.startup.processNextTick.process._tickCallback (node.js:245:9)

publish normally, not shrinkwrap

for some reason you published using shrinkwrap and included all the devDependencies.

i definitely don't need mocha in my production app.

Remove npm-shrinkwrap.json

  1. npm-shrinkwrap includes dev dependencies which forces users to always download them (like mocha) even if they are not doing development.
  2. npm-shrinkwrap is designed for app authors to lock down their dependencies. Specific modules can be locked down in package.json if there is a known need, otherwise the policy should be flexible.

"npm ERR! cb() never called!"

I'm getting this error when I try to install sendgrid... I've tried a couple different versions of node&npm, but I haven't been able to figure it out.

$ npm -d install sendgrid
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info retry registry request attempt 1 at 20:44:34
npm http GET https://registry.npmjs.org/sendgrid
npm http 304 https://registry.npmjs.org/sendgrid
npm info install [email protected] into /home/andrew/sunrise
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid unbuild
npm info preinstall [email protected]
npm info shrinkwrap file "/home/andrew/sunrise/node_modules/sendgrid/npm-shrinkwrap.json"
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/underscore/1.3.3
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/nodemailer/0.3.21
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/mocha/1.3.0
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/mime/1.2.7
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/step/0.0.5
npm info retry registry request attempt 1 at 20:44:35
npm http GET https://registry.npmjs.org/chai/1.1.1
npm http 304 https://registry.npmjs.org/underscore/1.3.3
npm http 304 https://registry.npmjs.org/step/0.0.5
npm http 304 https://registry.npmjs.org/mime/1.2.7
npm http 304 https://registry.npmjs.org/chai/1.1.1
npm http 304 https://registry.npmjs.org/mocha/1.3.0
npm http 304 https://registry.npmjs.org/nodemailer/0.3.21
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/step unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/underscore unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mime unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/chai unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer unbuild
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/step
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mime
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/chai
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/underscore
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info install [email protected]
npm info install [email protected]
npm info install [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/mailcomposer/0.1.15
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/simplesmtp/0.1.18
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/commander/0.6.1
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/growl/1.5.1
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/jade/0.26.3
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/diff/1.0.2
npm info retry registry request attempt 1 at 20:44:39
npm http GET https://registry.npmjs.org/debug/0.7.0
npm http 304 https://registry.npmjs.org/simplesmtp/0.1.18
npm http 304 https://registry.npmjs.org/jade/0.26.3
npm WARN package.json [email protected] No README.md file found!
npm http 304 https://registry.npmjs.org/diff/1.0.2
npm http 304 https://registry.npmjs.org/growl/1.5.1
npm http 304 https://registry.npmjs.org/debug/0.7.0
npm http 304 https://registry.npmjs.org/mailcomposer/0.1.15
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer
npm info installOne [email protected]
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/simplesmtp unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/mailcomposer unbuild
npm http 304 https://registry.npmjs.org/commander/0.6.1
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/jade unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/diff unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/growl unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/debug unbuild
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/commander unbuild
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info preinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/growl
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/commander
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/debug
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/diff
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info install [email protected]
npm info install [email protected]
npm info install [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info postinstall [email protected]
npm info retry registry request attempt 1 at 20:44:41
npm http GET https://registry.npmjs.org/rai/0.1.6
npm info retry registry request attempt 1 at 20:44:42
npm http GET https://registry.npmjs.org/mimelib-noiconv/0.1.9
npm info retry registry request attempt 1 at 20:44:42
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/rai/0.1.6
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/simplesmtp
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/simplesmtp/node_modules/rai unbuild
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/jade
npm info installOne [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/jade/node_modules/mkdirp unbuild
npm info preinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/jade/node_modules/mkdirp
npm info linkStuff [email protected]
npm http 304 https://registry.npmjs.org/mimelib-noiconv/0.1.9
npm info install [email protected]
npm info postinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha/node_modules/jade
npm info install [email protected] into /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/mailcomposer
npm info installOne [email protected]
npm info linkStuff [email protected]
npm info /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/mailcomposer/node_modules/mimelib-noiconv unbuild
npm info install [email protected]
npm info postinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/mocha
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info preinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/mailcomposer/node_modules/mimelib-noiconv
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info build /home/andrew/sunrise/node_modules/sendgrid/node_modules/nodemailer/node_modules/mailcomposer
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm ERR! cb() never called!
npm ERR! not ok code 0

SmtpapiHeaders does not exist.

In the README.MD, it says the smtpapi parameter is represented by sen(d)grid.SmtpapiHeaders(). I'm guessing this makes a call to instantiate the smtpapi class however this method does not actually exist in the sendgrid library.

This prevents me from using an X-SMTPAPI headers without having to also instantiate sendgrid.Email

Cannot create filter with Sendgrid

I could not add a filter, as per the README. Is there a way to do this?

      email = new sendgrid.Email();
      email.addFilter('subscriptiontrack', 'enable', 1)
      email.addFilter('subscriptiontrack', "text/plain", "If you would like to unsubscribe and stop receiving these emails click here: <% %>.")
     # calls an invalid method

Cannot send?

Im not sure if this is sendmail, or my own code, but it's working on my live site right now.

I am trying to run a mocha test with my web app, and I am not getting any feedback from the callback of sendgrid.send({payload}, callback); I have a console.log() in there, and nothing is happening... and... the email never got sent!.. Payload looks fine.

Issue with enumerable properties on Array object

When the Array object's prototype is polyfilled with any [enumerable] property, the Email.toWebFormat adds a 'files[undefined]' property to the returned web formatted payload. This ends up being an empty file attachment in the email.

Ex:

Array['testMethod'] = function() { return 'testMethod'; };
var email = new Email({ to: '[email protected]' });
var formatted = email.toWebFormat();

The reason this happens is because of the use of for..in loop to iterate over the files array in an email to convert it to web format. A fix would be for the user to use Object.defineProperty to make the property non-enumerable to for Email to not use for..in and rely on the ES5 forEach or _.forEach.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.