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 | const express = require('express'), swig = require('swig'), mailer = require('express-mailer'), path = require('path'), app = express(); mailer.extend(app, { secureConnection: false, transportMethod: 'SMTP', auth: { user: 'monemail@gmail.com', pass: 'monmdp' } }); 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){ app.mailer.send('email', { to: 'awoken(cfaux)@email.com', from: req.body.email, 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'); |
+0
-0