-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendmail.js
More file actions
50 lines (39 loc) · 1.2 KB
/
sendmail.js
File metadata and controls
50 lines (39 loc) · 1.2 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
var express = require("express");
var myParser = require("body-parser");
var nodemailer = require("nodemailer");
var app = express();
var cors = require('cors');
app.use(cors());
app.use(myParser.urlencoded({
extended : true
}));
app.post("/sendEmail", function(request, response) {
console.log(request.body);
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service : 'Gmail',
auth : {
user : ',
pass : ''
}
});
// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails
// setup e-mail data with unicode symbols
var mailOptions = {
from : request.body.email, // sender address
to : '', // list of receivers
subject : 'Hello ✔', // Subject line
text : request.body.content + ". From: " + request.body.sender, // plaintext body
//html: '<b>Hello world ✔</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
response.send("ההודעה נשלחה בהצלחה! תודה רבה.");
});
app.listen(8024);