m1gu3l / parse-sendgrid-mailer Goto Github PK
View Code? Open in Web Editor NEWParse.com Cloud Code module
License: MIT License
Parse.com Cloud Code module
License: MIT License
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! ๐ :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.