-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
56 lines (47 loc) · 1.42 KB
/
Copy pathtest.js
File metadata and controls
56 lines (47 loc) · 1.42 KB
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
46
47
48
49
50
51
52
53
54
55
56
var api_key = 'key-6134e0d7f8506d0c32adc4e0896ba3d6';
var domain = 'sandbox6e50aeb53ca94939b1b8b19aa3f157af.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var mailcomposer = require('mailcomposer');
var fs = require('fs');
var path = require('path');
var filepath = path.join(__dirname, 'test.html');
var mihai = fs.readFileSync(filepath);
var mail = mailcomposer({
from: 'you@samples.mailgun.org',
to: 'ditamihai@gmail.com',
subject: 'Test email subject',
text: 'Test email text',
html: mihai
});
mail.build(function(mailBuildError, message) {
var dataToSend = {
to: 'ditamihai@gmail.com',
message: message.toString('ascii')
};
mailgun.messages().sendMime(dataToSend, function (sendError, body) {
if (sendError) {
console.log(sendError);
return;
}
});
});
// var data = {
// from: 'Excited User <me@samples.mailgun.org>',
// to: 'ditamihai@gmail.com',
// subject: 'Hello',
// text: 'Testing some Mailgun awesomness!',
// attachment: filepath
// };
// mailgun.messages().send(data, function (error, body) {
// console.log(body);
// });
// var data = {
// from: 'Excited User <me@samples.mailgun.org>',
// to: 'ditamihai@gmail.com',
// subject: 'Hello',
// message: filepath,
// contentType: 'text/html'
// };
// mailgun.messages().sendMime(data, function (err, body) {
// console.log(body);
// });