loopbackjs – 发送带有回送电子邮件数据源附件的电子邮件

是否可以使用loopback email数据源发送附件?

我在源文档中看到的只有以下字段:

> @property {String}到电子邮件收件人.需要.
>来自电子邮件发件人地址的@property {String}.需要.
> @property {String} subject电子邮件主题字符串.需要.
> @property {String} text电子邮件的文本正文.
> @property {String} html电子邮件的HTML正文.

最佳答案
docs

Nodemailer: Where to Find Documentation

The email connector is
essentially a LoopBack-integrated interface to the 07001 library.
This page gives a usage example; for full documentation of
configuration options, refer to the 07002.

Here’s where nodemailer have documented attachments.

以下是环回上下文中不同类型附件的示例:

app.models.Email.send({
  to: 'example@example.com',
  from: 'no-reply@example.com',
  subject: 'Email Subject',
  html: '<b>Hello</b>',
  attachments: [
    {   // utf-8 string as an attachment
      filename: 'text1.txt',
      content: 'hello world!'
    },
    {   // binary buffer as an attachment
      filename: 'text2.txt',
      content: new Buffer('hello world!','utf-8')
    },
    {   // file on disk as an attachment
      filename: 'text3.txt',
      path: '/path/to/file.txt' // stream this file
    },
    {   // filename and content type is derived from path
      path: '/path/to/file.txt'
    },
    {   // stream as an attachment
      filename: 'text4.txt',
      content: fs.createReadStream('file.txt')
    },
    {   // define custom content type for the attachment
      filename: 'text.bin',
      content: 'hello world!',
      contentType: 'text/plain'
    },
    {   // use URL as an attachment
      filename: 'license.txt',
      path: 'https://raw.github.com/nodemailer/nodemailer/master/LICENSE'
    },
    {   // encoded string as an attachment
      filename: 'text1.txt',
      content: 'aGVsbG8gd29ybGQh',
      encoding: 'base64'
    },
    {   // data uri as an attachment
      path: 'data:text/plain;base64,aGVsbG8gd29ybGQ='
    },
    {
      // use pregenerated MIME node
      raw: 'Content-Type: text/plain\r\n' +
        'Content-Disposition: attachment;\r\n' +
        '\r\n' +
        'Hello world!'
    }
  ],
}, err => {
  if (err) {
    throw err;
  }
});

转载注明原文:loopbackjs – 发送带有回送电子邮件数据源附件的电子邮件 - 代码日志