Skip to content

Commit

Permalink
Fix back on mailjet because data.gouv.fr is blocked
Browse files Browse the repository at this point in the history
  • Loading branch information
Flightan committed Sep 14, 2015
1 parent b40f558 commit 0f91e9f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
6 changes: 3 additions & 3 deletions pm2.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

"NODE_TLS_REJECT_UNAUTHORIZED": 0,

"SMTP_USER": "[email protected]",
"SMTP_PASS": "pass",
"SMTP_HOST": "yourdomain.com"
"MAILJET_SENDER": "[email protected]",
"MAILJET_API_KEY": "mailjet_api_key",
"MAILJET_SECRET_KEY": "mailjet_secret_key"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions server/api/demande/demande.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function sendConfirmationToUser(email, demande, college, req) {
body += 'Vous recevrez une réponse avant le 15 octobre au plus tard.<br>';
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 + '.<body><html>';

sendMail(email, config.user, subject, body);
sendMail(email, '[email protected]', subject, body);
req.log.info('Notification sent to: ' + email);
}

Expand All @@ -84,7 +84,7 @@ function sendNotificationToAgent(identite, college, req) {
'<h3><a href="' + dashboard + '">Cliquez ici pour voir la liste des demandes passées</a></h3>\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, '[email protected]', subject, body);
req.log.info('Notification sent to: ' + etablissement.contact);
}
});
Expand Down
18 changes: 5 additions & 13 deletions server/components/mail/send-mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
to: to,
replyTo: replyTo,
subject: 'Bourse - ' + subject,
html: body
};
Expand Down
10 changes: 10 additions & 0 deletions server/config/environment/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,15 @@ module.exports = {
pass: 'password'
},

mailjet: {
port: 465,
host: '',
secure: true,
auth: {
user: '',
pass: ''
}
},

port: 5000
};
11 changes: 11 additions & 0 deletions server/config/environment/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

};

0 comments on commit 0f91e9f

Please sign in to comment.