UNPKG

1.39 kBJavaScriptView Raw
1var sendmail = require('../sendmail')({silent: true})
2sendmail({
3 from: 'test@yourdomain.com',
4 to: 'info@yourdomain.com',
5 replyTo: 'jason@yourdomain.com',
6 subject: 'MailComposer sendmail',
7 html: 'Mail of test sendmail ',
8 attachments: [
9 { // utf-8 string as an attachment
10 filename: 'text1.txt',
11 content: 'hello world!'
12 },
13 { // binary buffer as an attachment
14 filename: 'text2.txt',
15 content: new Buffer('hello world!', 'utf-8')
16 },
17 // { // file on disk as an attachment
18 // filename: 'text3.txt',
19 // path: '/path/to/file.txt' // stream this file
20 // },
21 // { // filename and content type is derived from path
22 // path: '/path/to/file.txt'
23 // },
24 { // define custom content type for the attachment
25 filename: 'text.bin',
26 content: 'hello world!',
27 contentType: 'text/plain'
28 },
29 { // use URL as an attachment
30 filename: 'license.txt',
31 path: 'https://raw.github.com/guileen/node-sendmail/master/LICENSE'
32 },
33 { // encoded string as an attachment
34 filename: 'text1.txt',
35 content: 'aGVsbG8gd29ybGQh',
36 encoding: 'base64'
37 },
38 { // data uri as an attachment
39 path: 'data:text/plain;base64,aGVsbG8gd29ybGQ='
40 }
41 ]
42}, function (err, reply) {
43 console.log(err && err.stack)
44 console.dir(reply)
45})
46