mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added from
parameter for member emails (#11222)
* Added from parameter for member emails no issue - Passed in the `from` parameter when initializing members mailer to be able to customize outgoing address - Extends GhsotMailer to accept a from parameter from the outside
This commit is contained in:
parent
816bec28c2
commit
1b04b48ffd
2 changed files with 18 additions and 2 deletions
|
@ -37,7 +37,7 @@ function getFromAddress(requestedFromAddress) {
|
|||
|
||||
function createMessage(message) {
|
||||
return Object.assign({}, message, {
|
||||
from: getFromAddress(),
|
||||
from: getFromAddress(message.from),
|
||||
generateTextFromHTML: true,
|
||||
encoding: 'base64'
|
||||
});
|
||||
|
|
|
@ -158,6 +158,13 @@ function getRequirePaymentSetting() {
|
|||
return !!subscriptionSettings.requirePaymentForSignup;
|
||||
}
|
||||
|
||||
// NOTE: the function is an exact duplicate of one in GhostMailer should be extracted
|
||||
// into a common lib once it needs to be reused anywhere else again
|
||||
function getDomain() {
|
||||
const domain = urlUtils.urlFor('home', true).match(new RegExp('^https?://([^/:?#]+)(?:[/:?#]|$)', 'i'));
|
||||
return domain && domain[1];
|
||||
}
|
||||
|
||||
module.exports = createApiInstance;
|
||||
|
||||
function createApiInstance() {
|
||||
|
@ -182,7 +189,16 @@ function createApiInstance() {
|
|||
if (process.env.NODE_ENV !== 'production') {
|
||||
common.logging.warn(message.text);
|
||||
}
|
||||
return ghostMailer.send(Object.assign({subject: 'Signin'}, message));
|
||||
|
||||
let msg = Object.assign({subject: 'Signin'}, message);
|
||||
const subscriptionSettings = settingsCache.get('members_subscription_settings');
|
||||
|
||||
if (subscriptionSettings && subscriptionSettings.fromAddress) {
|
||||
let from = `${subscriptionSettings.fromAddress}@${getDomain()}`;
|
||||
msg = Object.assign({from: from}, msg);
|
||||
}
|
||||
|
||||
return ghostMailer.send(msg);
|
||||
}
|
||||
},
|
||||
getText(url, type) {
|
||||
|
|
Loading…
Add table
Reference in a new issue