-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
43 lines (35 loc) · 913 Bytes
/
app.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
var express = require('express'),
swig = require('swig'),
mailer = require('express-mailer'),
path = require('path'),
app = express();
app.use(express.logger());
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'public')));
app.engine('html', swig.renderFile);
app.set('views', __dirname+'/views');
app.set('view engine', 'html');
app.get('/', function(req, res){
res.render('index');
});
app.post('/contact', function(req, res, next){
mailer.extend(app, {
from: req.body.email,
host: 'smtp.free.fr',
secureConnection: false,
port: 25,
transportMethod: 'SMTP'
});
app.mailer.send('email', {
to: '[email protected]',
subject: req.body.subject,
message: req.body.message
}, function(err){
if(err){
console.log('On a une erreur!');return;
}
res.send('Email envoyé');
});
});
app.listen(3000);
console.log('App is running');