diff --git a/pm2.json.sample b/pm2.json.sample
index e9db03c..3043d1b 100644
--- a/pm2.json.sample
+++ b/pm2.json.sample
@@ -21,9 +21,9 @@
"NODE_TLS_REJECT_UNAUTHORIZED": 0,
- "SMTP_USER": "abc@yourdomain.com",
- "SMTP_PASS": "pass",
- "SMTP_HOST": "yourdomain.com"
+ "MAILJET_SENDER": "abc@yourdomain.com",
+ "MAILJET_API_KEY": "mailjet_api_key",
+ "MAILJET_SECRET_KEY": "mailjet_secret_key"
}
}
]
diff --git a/server/api/demande/demande.controller.js b/server/api/demande/demande.controller.js
index 6866d4b..07f2d23 100644
--- a/server/api/demande/demande.controller.js
+++ b/server/api/demande/demande.controller.js
@@ -63,7 +63,7 @@ function sendConfirmationToUser(email, demande, college, req) {
body += 'Vous recevrez une réponse avant le 15 octobre au plus tard.
';
body += 'Merci d’avoir utilisé ce service et en cas de question n\'hésitez pas à nous écrire à "' + college.contact + '" ou à contacter l\'intendance au ' + college.telephone + '.
';
- sendMail(email, config.user, subject, body);
+ sendMail(email, 'bourse@sgmap.fr', subject, body);
req.log.info('Notification sent to: ' + email);
}
@@ -84,7 +84,7 @@ function sendNotificationToAgent(identite, college, req) {
'\n' +
'Si le lien ne marche pas, vous pouvez copier/coller cette adresse dans votre navigateur:\n' + dashboard;
- sendMail(email, config.user, subject, body);
+ sendMail(email, 'bourse@sgmap.fr', subject, body);
req.log.info('Notification sent to: ' + etablissement.contact);
}
});
diff --git a/server/components/mail/send-mail.js b/server/components/mail/send-mail.js
index e7df15c..056feac 100644
--- a/server/components/mail/send-mail.js
+++ b/server/components/mail/send-mail.js
@@ -3,25 +3,17 @@
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
-var config = require('../../config/environment').smtp;
+var config = require('../../config/environment').mailjet;
-exports.sendMail = function(to, from, subject, body, attachments, done) {
+exports.sendMail = function(to, replyTo, subject, body, attachments, done) {
var transporter = nodemailer.createTransport(
- smtpTransport({
- port: 587,
- host: config.host,
- secure: false,
- requireTLS: true,
- auth: {
- user: config.user,
- pass: config.pass
- }
- })
+ smtpTransport(config)
);
var mailOptions = {
- from: from,
+ from: 'bourse@sgmap.fr',
to: to,
+ replyTo: replyTo,
subject: 'Bourse - ' + subject,
html: body
};
diff --git a/server/config/environment/development.js b/server/config/environment/development.js
index 6459b15..087d21e 100644
--- a/server/config/environment/development.js
+++ b/server/config/environment/development.js
@@ -14,5 +14,15 @@ module.exports = {
pass: 'password'
},
+ mailjet: {
+ port: 465,
+ host: '',
+ secure: true,
+ auth: {
+ user: '',
+ pass: ''
+ }
+ },
+
port: 5000
};
diff --git a/server/config/environment/production.js b/server/config/environment/production.js
index b4cecbd..626c10d 100644
--- a/server/config/environment/production.js
+++ b/server/config/environment/production.js
@@ -21,5 +21,16 @@ module.exports = {
host: process.env.SMTP_HOST,
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS
+ },
+
+ mailjet: {
+ port: 465,
+ host: 'in.mailjet.com',
+ secure: true,
+ auth: {
+ user: process.env.MAILJET_API_KEY,
+ pass: process.env.MAILJET_SECRET_KEY
+ }
}
+
};