forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix email sending fail when blog title has a comma
no issue - We send emails from Blog Title <[email protected]>, but it should be from "Blog Title" <[email protected]> - 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
- Loading branch information
Showing
2 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,57 +71,57 @@ describe('Mail', function () { | |
it('should use from address as configured in config.js', function () { | ||
config.set({ | ||
mail: { | ||
from: 'Blog Title <[email protected]>' | ||
from: '"Blog Title" <[email protected]>' | ||
} | ||
}); | ||
mailer.from().should.equal('Blog Title <[email protected]>'); | ||
mailer.from().should.equal('"Blog Title" <[email protected]>'); | ||
}); | ||
|
||
it('should fall back to [blog.title] <ghost@[blog.url]> as from address', function () { | ||
// Standard domain | ||
config.set({url: 'http://default.com', mail: {from: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
|
||
// Trailing slash | ||
config.set({url: 'http://default.com/', mail: {from: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
|
||
// Strip Port | ||
config.set({url: 'http://default.com:2368/', mail: {from: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
}); | ||
|
||
it('should use mail.from if both from and fromaddress are present', function () { | ||
// Standard domain | ||
config.set({mail: {from: 'bar <[email protected]>', fromaddress: 'Qux <[email protected]>'}}); | ||
mailer.from().should.equal('bar <[email protected]>'); | ||
config.set({mail: {from: '"bar" <[email protected]>', fromaddress: '"Qux" <[email protected]>'}}); | ||
mailer.from().should.equal('"bar" <[email protected]>'); | ||
}); | ||
|
||
it('should attach blog title if from or fromaddress are only email addresses', function () { | ||
// from and fromaddress are both set | ||
config.set({mail: {from: '[email protected]', fromaddress: '[email protected]'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
|
||
// only from set | ||
config.set({mail: {from: '[email protected]', fromaddress: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
|
||
// only fromaddress set | ||
config.set({mail: {from: null, fromaddress: '[email protected]'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('Test <[email protected]>'); | ||
mailer.from().should.equal('"Test" <[email protected]>'); | ||
}); | ||
|
||
it('should ignore theme title if from address is Title <[email protected]> format', function () { | ||
// from and fromaddress are both set | ||
config.set({mail: {from: 'R2D2 <[email protected]>', fromaddress: 'C3PO <[email protected]>'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('R2D2 <[email protected]>'); | ||
config.set({mail: {from: '"R2D2" <[email protected]>', fromaddress: '"C3PO" <[email protected]>'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('"R2D2" <[email protected]>'); | ||
|
||
// only from set | ||
config.set({mail: {from: 'R2D2 <[email protected]>', fromaddress: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('R2D2 <[email protected]>'); | ||
config.set({mail: {from: '"R2D2" <[email protected]>', fromaddress: null}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('"R2D2" <[email protected]>'); | ||
|
||
// only fromaddress set | ||
config.set({mail: {from: null, fromaddress: 'C3PO <[email protected]>'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('C3PO <[email protected]>'); | ||
config.set({mail: {from: null, fromaddress: '"C3PO" <[email protected]>'}, theme: {title: 'Test'}}); | ||
mailer.from().should.equal('"C3PO" <[email protected]>'); | ||
}); | ||
}); |