-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailOptions.js
195 lines (193 loc) · 5.71 KB
/
mailOptions.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
require("./index.js");
var bunyan = require("bunyan");
var nodemailer = require("nodemailer");
var app = require("express");
// module.exports = function(mail, auth) {
var bunyan = require("bunyan");
var nodemailer = require("nodemailer");
var logger = bunyan.createLogger({
name: "nodemailer"
});
logger.level("trace");
var transporter = nodemailer.createTransport(
{
service: "Gmail",
auth: {
type: "SMTP",
user: "seth.atxwebs@gmail.com",
pass: "gouuvbgiwtcnnbps"
// expires: 12345
},
logger,
debug: false // include SMTP traffic in the logs
},
{
// default message fields
// sender info
from: "StackRiot <stackriot@gmail.com>",
headers: {
"X-Laziness-level": 1000 // just an example header, no need to use this
}
}
);
//
// console.log('SMTP Configured');
//
// // Message object
// var message = {
//
// // Comma separated list of recipients
// to: 'Seth Bergman <seth.atxwebs@gmail.com>',
//
// // Subject of the message
// subject: 'Nodemailer is unicode friendly ✔ #', //
//
// // plaintext body
// text: 'Hello to myself!',
//
// // HTML body
// html: '<p><b>Hello</b> to myself <img src="cid:note@example.com"/></p>' +
// '<p>Here\'s a nyan cat for you as an embedded attachment:<br/><img src="cid:nyan@example.com"/></p>',
//
// // Apple Watch specific HTML body
// watchHtml: '<b>Hello</b> to myself',
//
// // An array of attachments
// attachments: [
//
// // String attachment
// {
// filename: 'notes.txt',
// content: 'Some notes about this e-mail',
// contentType: 'text/plain' // optional, would be detected from the filename
// },
//
// // Binary Buffer attachment
// {
// filename: 'image.png',
// content: new Buffer('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
// '//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
// 'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC', 'base64'),
//
// cid: 'note@example.com' // should be as unique as possible
// },
//
// // File Stream attachment
// {
// filename: 'nyan cat ✔.gif',
// path: __dirname + '/assets/nyan.gif',
// cid: 'nyan@example.com' // should be as unique as possible
// }
// ]
// };
console.log("Sending Mail");
transporter.sendMail(message, (error, info) => {
if (error) {
console.log("Error occurred");
console.log(error.message);
return;
}
console.log("Message sent successfully!");
console.log('Server responded with "%s"', info.response);
console.log("Message sent successfully!");
console.log('Server responded with "%s"', info.response);
transporter.close();
});
module.exports = transporter;
// mailOptions: {
// to: req.query.to,
// subject: 'Contact Form Message',
// from: "Contact Form Request" + "<" + req.query.from + '>',
// html: "From: " + req.query.name + "<br>" +
// "User's email: " + req.query.user + "<br>" + "Message: " + req.query.text,
//
// service: 'Gmail',
// auth: {
// // enter your gmail account
// user: 'seth.atxwebs@gmail.com',
// // enter your gmail password
// pass: 'gouuvbgiwtcnnbps'
// }
// }
// Create a SMTP transporter object
// var transporter = nodemailer.createTransport({
// service: 'Gmail',
// auth: {
// user: 'seth.atxwebs@gmail.com',
// pass: 'gouuvbgiwtcnnbps'
// // expires: 12345
// },
// logger,
// debug: true // include SMTP traffic in the logs
// }, {
// // default message fields
//
// // sender info
// from: 'StackRiot <stackriot@gmail.com>',
// headers: {
// 'X-Laziness-level': 1000 // just an example header, no need to use this
// }
// });
//
// console.log('SMTP Configured');
//
// // Message object
// var message = {
//
// // Comma separated list of recipients
// to: 'Seth Bergman <seth.atxwebs@gmail.com>',
//
// // Subject of the message
// subject: 'Nodemailer is unicode friendly ✔ #', //
//
// // plaintext body
// text: 'Hello to myself!',
//
// // HTML body
// html: '<p><b>Hello</b> to myself <img src="cid:note@example.com"/></p>' +
// '<p>Here\'s a nyan cat for you as an embedded attachment:<br/><img src="cid:nyan@example.com"/></p>',
//
// // Apple Watch specific HTML body
// watchHtml: '<b>Hello</b> to myself',
//
// // An array of attachments
// attachments: [
//
// // String attachment
// {
// filename: 'notes.txt',
// content: 'Some notes about this e-mail',
// contentType: 'text/plain' // optional, would be detected from the filename
// },
//
// // Binary Buffer attachment
// {
// filename: 'image.png',
// content: new Buffer('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
// '//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
// 'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC', 'base64'),
//
// cid: 'note@example.com' // should be as unique as possible
// },
//
// // File Stream attachment
// {
// filename: 'nyan cat ✔.gif',
// path: __dirname + '/assets/nyan.gif',
// cid: 'nyan@example.com' // should be as unique as possible
// }
// ]
// };
// }
// console.log('Sending Mail');
// transporter.sendMail(message, (error, info) => {
// if (error) {
// console.log('Error occurred');
// console.log(error.message);
// return;
// }
// console.log('Message sent successfully!');
// console.log('Server responded with "%s"', info.response);
// transporter.close();
// });
// })