0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Mail settings are per environment

closes #624

- example mail setting in development config
- updated mail module & tests
This commit is contained in:
Hannah Wolfe 2013-09-04 16:15:21 +01:00
parent c45f911a1e
commit c469d05c46
3 changed files with 20 additions and 20 deletions

View file

@ -19,18 +19,6 @@ config.activePlugins = [
];
config.mail = {
transport: 'sendgrid',
host: 'smtp.sendgrid.net',
options: {
service: 'Sendgrid',
auth: {
user: '', // Super secret username
pass: '' // Super secret password
}
}
};
// ## Default Navigation Items
// Add new objects here to extend the menu output by {{nav}}
config.nav = [
@ -90,7 +78,19 @@ config.env = {
port: '2368'
},
// The url to use when providing links to the site; like RSS and email.
url: 'http://127.0.0.1:2368'
url: 'http://127.0.0.1:2368',
// Example mail config
mail: {
transport: 'sendgrid',
host: 'smtp.sendgrid.net',
options: {
service: 'Sendgrid',
auth: {
user: '', // Super secret username
pass: '' // Super secret password
}
}
}
},
staging: {

View file

@ -18,7 +18,7 @@ GhostMailer.prototype.init = function (ghost) {
this.api = require('./api');
var self = this,
config = ghost.config();
config = ghost.config().env[process.env.NODE_ENV];
if (config.mail && config.mail.transport && config.mail.options) {
this.createTransport(config);

View file

@ -75,7 +75,7 @@ describe("Mail", function () {
});
it('should setup SMTP transport on initialization', function (done) {
fakeConfig.mail = SMTP;
fakeConfig.env[process.env.NODE_ENV].mail = SMTP;
ghost.mail.init(ghost).then(function(){
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SMTP');
@ -85,7 +85,7 @@ describe("Mail", function () {
});
it('should setup sendmail transport on initialization', function (done) {
fakeConfig.mail = SENDMAIL;
fakeConfig.env[process.env.NODE_ENV].mail = SENDMAIL;
ghost.mail.init(ghost).then(function(){
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
@ -95,7 +95,7 @@ describe("Mail", function () {
});
it('should fallback to sendmail if no config set', function (done) {
fakeConfig.mail = null;
fakeConfig.env[process.env.NODE_ENV].mail = null;
ghost.mail.init(ghost).then(function(){
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
@ -105,7 +105,7 @@ describe("Mail", function () {
});
it('should fallback to sendmail if config is empty', function (done) {
fakeConfig.mail = {};
fakeConfig.env[process.env.NODE_ENV].mail = {};
ghost.mail.init(ghost).then(function(){
ghost.mail.should.have.property('transport');
ghost.mail.transport.transportType.should.eql('SENDMAIL');
@ -115,7 +115,7 @@ describe("Mail", function () {
});
it('should disable transport if config is empty & sendmail not found', function (done) {
fakeConfig.mail = {};
fakeConfig.env[process.env.NODE_ENV].mail = {};
ghost.mail.detectSendmail.restore();
sandbox.stub(ghost.mail, "detectSendmail", when.reject);
ghost.mail.init(ghost).then(function(){
@ -125,7 +125,7 @@ describe("Mail", function () {
});
it('should disable transport if config is empty & platform is win32', function (done) {
fakeConfig.mail = {};
fakeConfig.env[process.env.NODE_ENV].mail = {};
ghost.mail.detectSendmail.restore();
ghost.mail.isWindows.restore();
sandbox.stub(ghost.mail, 'isWindows', function(){ return true });