Code Monkey home page Code Monkey logo

parse-sendgrid-mailer's People

Contributors

crisson avatar m1gu3l avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

parse-sendgrid-mailer's Issues

TypeError: Cannot read property 'length' of undefined

Hi, was very excited when I found this library as I need to send PDF attachments, but when I do this simple example:

mailer
    .mail()
    .property('from', '[email protected]')
    .property('to', '[email protected]')
    .property('subject', 'Report')
    .property('text', 'Lorem ipsum dolor sit amet')
    .send()

I get the following error, when the code reaches send().

Result: TypeError: Cannot read property 'length' of undefined
    at Function.Buffer.concat (buffer.js:667:20)
    at SendGridEmail.send (lib/sendgrid-mailer.js:66:22)
    at e.<anonymous> (reportStaticMails.js:24:14)
    at e.i (Parse.js:14:27703)
    at e.a.value (Parse.js:14:27063)
    at e.<anonymous> (Parse.js:14:27774)
    at e.i (Parse.js:14:27703)
    at Parse.js:14:28316
    at l (Parse.js:14:28120)
    at e.a.value (Parse.js:14:28301)

Both my Cloud Code and Javascript SDK is fully up to date

Discovery1: Think it was a scope issue with this will create a pull request in a few hours.

SendGridEmail.prototype.send = function() {
    var _this = this;
    this._buffers.push( new Buffer('--' + boundary + '--') );

    return Parse.Cloud.httpRequest({
        url: 'https://api.sendgrid.com/api/mail.send.json',
        method: 'POST',
        headers: {
            'Content-Type': 'multipart/form-data; boundary=' + boundary
        },
        body: Buffer.concat(_this._buffers)
    });
} 

Discovery2: To attach a pdf, I had to do:

var Buffer = require('buffer').Buffer;

mailer.mail().attach('report.pdf', 'application/pdf', new Buffer(fileBuffer)) 

No clue if that can be avoided, otherwise it might be worth updating the README.

Final note: I would gladly buy you a beer now that I am able to send PDF's, this wrapper is also cleaner to use than sendgrid-parse in my opinion. So kudos for good work! ๐Ÿ‘ :)

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.