-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
45 lines (38 loc) · 1.32 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//var email = require('emailjs');
var email = require('./email');
var os = require('os');
SMTP =
{
USER: 'username',
PASS: 'password',
HOST: "smtp.gmail.com",
PORT: null, // emailjs will use default SMTP port standards (587, 465, 25) where appropriate
SSL: false, // use ssl from begin to end on smtp connection, accepts object of (key, ca, certs) as well...
TLS: true // use STARTTLS encrypting stream after initial smtp connection
};
MESSAGE =
{
DOMAIN: os.hostname(),
FROM: '[email protected]',
SUBJECT: 'testing emailjs',
TEXT: 'i hope this works',
HTML: '<html><body>i <i>hope</i> <b>this</b> works</body></html>',
ATTACH:
{
PATH: '/path/to/file.tar.gz',
TYPE: 'application/x-compressed-tar',
NAME: 'renamed.tar.gz'
}
};
var server = email.server.connect({
user: SMTP.USER,
password: SMTP.PASS,
host: SMTP.HOST,
port: SMTP.PORT,
tls: SMTP.TLS,
ssl: SMTP.SSL,
domain: MESSAGE.DOMAIN});
var msg = email.message.create({text:MESSAGE.TEXT, from:MESSAGE.FROM, to:MESSAGE.TO, subject:MESSAGE.SUBJECT});
msg.attach_alternative(MESSAGE.HTML).attach(MESSAGE.ATTACH.PATH, MESSAGE.ATTACH.TYPE, MESSAGE.ATTACH.NAME);
server.send(msg, function(err, message) { console.log(err || message); });