0

This Meteor server code tries to attach a pdf file but giving errors on server startup. I want avoid saving the file locally first. it is using pascoual:pdfkit.
The error I am getting is:

Error: Message failed: 421 Timeout waiting for data from client.

Meteor doc point to mailcomposer documentation, but the issue is how to integrate the pdf doc in the attachments. Any ideas? Thanks

Meteor.startup(() => {
  Invoice.email();
};

// invoice.js
use strict";
let PDFDocument = require ('pdfkit');
let metaData = {
  'Title': 'Invoice',
  'Author': 'myName',
};
export const Invoice = {
  'make': function () {
    let doc = new PDFDocument(metaData);
    doc.text('my company').text('company number');

    return doc;
  },
  'email': function () {
    let inv = Invoice.make();
    Email.send({
      to: 'myemail@comp.com',
      from: 'personal@company.com',
      subject: 'Invoice',
      text: ' Please see the attached invoice',
      attachments: {
        filename: 'invoice.pdf',
        content: inv // <=== this is the issue
     });
  }
};
Fred J.
  • 5,759
  • 10
  • 57
  • 106

1 Answers1

0

As per Documentation, the content definition is

content - String, Buffer or a Stream contents for the attachment

Link to mailcomposer documentation.

If I am not wrong the Invoice.make() is not returning expecting format of blob. Kindly check the Stream and type so that you know you get what you are creating.

Link to more Supporting details

Ankur Soni
  • 5,725
  • 5
  • 50
  • 81