Open n-lavrenko opened 7 years ago
I just checked it's working
keystone-email : 1.0.5 which uses mailgun-js : 0.7.15 this is my code
new mailer('templates/emails/invoice.pug', {
transport: 'mailgun',
engine : 'pug',
}).send(
{ invoiceNumber: inv.invoiceNumber, orderNumber: this.ordernumber },
{
to : 'myemai',
from : 'fromemail',
apiKey : process.env.MAILGUN_API_KEY,
domain : process.env.MAILGUN_DOMAIN,
attachment: __dirname + `/../${pdf}`,
},
(err, resp) => {
console.log(err, resp);
}
);```
Hi there. I can't send an attachment file via MailGun. First of all: we don't have any documentation about attachments except on the MailGun site (but there is explaining about using module
mailgun-js
.Details:
req.files.file
and have a path to the file (so it's a absolute path to the temp folder on my MacOS).Email
:email.send(options, callback);
Mongoose model 'error' event fired on 'User' with error: source.on is not a function TypeError: source.on is not a function at Function.DelayedStream.create (/projects/metallita/node_modules/delayed-stream/lib/delayed_stream.js:33:10) at FormData.CombinedStream.append (/projects/metallita/node_modules/combined-stream/lib/combined_stream.js:43:37) at FormData.append (/projects/metallita/node_modules/keystone-email/node_modules/form-data/lib/form_data.js:68:3) at Request.prepareFormData (/projects/metallita/node_modules/keystone-email/node_modules/mailgun-js/lib/request.js:186:21) at Request.request (/projects/metallita/node_modules/keystone-email/node_modules/mailgun-js/lib/request.js:61:12) at Mailgun.request (/projects/metallita/node_modules/keystone-email/node_modules/mailgun-js/lib/mailgun.js:74:14) at constructor.(anonymous function) [as send] (/projects/metallita/node_modules/keystone-email/node_modules/mailgun-js/lib/build.js:101:24) at send (/projects/metallita/node_modules/keystone-email/lib/transports/mailgun/index.js:26:20) at /projects/metallita/node_modules/keystone-email/lib/Email.js:125:3 at /projects/metallita/node_modules/keystone-email/lib/Email.js:77:3 at Object.exports.renderFile (/projects/metallita/node_modules/pug/lib/index.js:412:12) at Email.exports.__express [as engine] (/projects/metallita/node_modules/pug/lib/index.js:455:11) at Email.render (/projects/metallita/node_modules/keystone-email/lib/Email.js:75:7) at Email.send (/projects/metallita/node_modules/keystone-email/lib/Email.js:123:7) at Email.email.send (/projects/metallita/node_modules/keystone/lib/email.js:102:8) at /projects/metallita/api/request.js:85:10 (anonymous) @ register.js:83 emitOne @ events.js:115 emit @ events.js:210 (anonymous) @ query.js:2333 runCallback @ timers.js:781 tryOnImmediate @ timers.js:743 processImmediate @ timers.js:714
let mailgun = require('mailgun-js')({ apiKey: process.env.MAILGUN_API_KEY, domain: process.env.MAILGUN_DOMAIN });
var data = { from: 'Excited User me@samples.mailgun.org', to: 'info@info.com', subject: 'Hello', text: 'Testing some Mailgun awesomness!', attachment: file.path };
mailgun.messages().send(data, function (error, body) { console.log(body); // success });