From 283deb246130ec9bdbe6371e3441521fb58c52e3 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 9 Jan 2015 21:03:03 +0000 Subject: [PATCH] Fix email sending fail when blog title has a comma no issue - We send emails from Blog Title , but it should be from "Blog Title" - It worked fine without quotes unless you have a comma in your Blog Title in which case different mail systems get confused in different ways --- core/server/mail.js | 2 +- core/test/unit/mail_spec.js | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/server/mail.js b/core/server/mail.js index 6d0ba6747b..683c1a23a3 100644 --- a/core/server/mail.js +++ b/core/server/mail.js @@ -43,7 +43,7 @@ GhostMailer.prototype.from = function () { if (!config.theme.title) { config.theme.title = 'Ghost at ' + this.getDomain(); } - from = config.theme.title + ' <' + from + '>'; + from = '"' + config.theme.title + '" <' + from + '>'; } return from; diff --git a/core/test/unit/mail_spec.js b/core/test/unit/mail_spec.js index 1103fa8621..9d30252b41 100644 --- a/core/test/unit/mail_spec.js +++ b/core/test/unit/mail_spec.js @@ -71,57 +71,57 @@ describe('Mail', function () { it('should use from address as configured in config.js', function () { config.set({ mail: { - from: 'Blog Title ' + from: '"Blog Title" ' } }); - mailer.from().should.equal('Blog Title '); + mailer.from().should.equal('"Blog Title" '); }); it('should fall back to [blog.title] as from address', function () { // Standard domain config.set({url: 'http://default.com', mail: {from: null}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); // Trailing slash config.set({url: 'http://default.com/', mail: {from: null}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); // Strip Port config.set({url: 'http://default.com:2368/', mail: {from: null}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); }); it('should use mail.from if both from and fromaddress are present', function () { // Standard domain - config.set({mail: {from: 'bar ', fromaddress: 'Qux '}}); - mailer.from().should.equal('bar '); + config.set({mail: {from: '"bar" ', fromaddress: '"Qux" '}}); + mailer.from().should.equal('"bar" '); }); it('should attach blog title if from or fromaddress are only email addresses', function () { // from and fromaddress are both set config.set({mail: {from: 'from@default.com', fromaddress: 'fa@default.com'}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); // only from set config.set({mail: {from: 'from@default.com', fromaddress: null}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); // only fromaddress set config.set({mail: {from: null, fromaddress: 'fa@default.com'}, theme: {title: 'Test'}}); - mailer.from().should.equal('Test '); + mailer.from().should.equal('"Test" '); }); it('should ignore theme title if from address is Title format', function () { // from and fromaddress are both set - config.set({mail: {from: 'R2D2 ', fromaddress: 'C3PO '}, theme: {title: 'Test'}}); - mailer.from().should.equal('R2D2 '); + config.set({mail: {from: '"R2D2" ', fromaddress: '"C3PO" '}, theme: {title: 'Test'}}); + mailer.from().should.equal('"R2D2" '); // only from set - config.set({mail: {from: 'R2D2 ', fromaddress: null}, theme: {title: 'Test'}}); - mailer.from().should.equal('R2D2 '); + config.set({mail: {from: '"R2D2" ', fromaddress: null}, theme: {title: 'Test'}}); + mailer.from().should.equal('"R2D2" '); // only fromaddress set - config.set({mail: {from: null, fromaddress: 'C3PO '}, theme: {title: 'Test'}}); - mailer.from().should.equal('C3PO '); + config.set({mail: {from: null, fromaddress: '"C3PO" '}, theme: {title: 'Test'}}); + mailer.from().should.equal('"C3PO" '); }); });