2017-01-12 50 views
2

是否可以使用环回电子邮件数据源发送附件?用环回电子邮件数据源发送带附件的电子邮件

我只能在源文件中看到的是这些领域:

  • @property {}字符串到电子邮件收件人。需要。
  • @property {String}来自电子邮件发件人地址。需要。
  • @property {String}主题电子邮件主题字符串。需要。
  • @property {String}文本电子邮件的文本正文。
  • @property {String} html电子邮件的HTML正文。
+0

我相信这个问题应留给开放,因为它不是在这种情况下重复的,这是明确作者的要求,这是在主题上,而不是太宽泛或基于意见。 –

+0

人们现在只是自动标记问题。它很荒谬 – dagda1

回答

4

docs

Nodemailer:哪里可以找到文档

电子邮件连接器是 基本上是一个loopback-集成接口的nodemailer库。 该页面给出了一个使用示例;有关 配置选项的完整文档,请参阅nodemailer documention

Here's where nodemailer have documented attachments.

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

app.models.Email.send({ 
    to: '[email protected]', 
    from: '[email protected]', 
    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; 
    } 
});