diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-03-28 20:52:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-28 20:52:39 +0300 |
commit | 0c36f5f4c27dce6207b1d8093f387d6a55a6da02 (patch) | |
tree | ad3ebadd5bb7e1da31b151e1d06a6e20309b493c /models/settings.js | |
parent | b3cd2f212599f8d0f9b841c5cf1dfaf57a84d8d7 (diff) | |
parent | 5db786e2ddca5bc416612778bb0de0d8338003eb (diff) | |
download | wekan-0c36f5f4c27dce6207b1d8093f387d6a55a6da02.tar.gz wekan-0c36f5f4c27dce6207b1d8093f387d6a55a6da02.tar.bz2 wekan-0c36f5f4c27dce6207b1d8093f387d6a55a6da02.zip |
Merge pull request #943 from Zokormazo/smtp
Don't send emails if missing smtp host
Diffstat (limited to 'models/settings.js')
-rw-r--r-- | models/settings.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/models/settings.js b/models/settings.js index 29b5f97c..0c2da4d3 100644 --- a/models/settings.js +++ b/models/settings.js @@ -35,6 +35,9 @@ Settings.attachSchema(new SimpleSchema({ })); Settings.helpers({ mailUrl () { + if (!this.mailServer.host) { + return null; + } if (!this.mailServer.username && !this.mailServer.password) { return `smtp://${this.mailServer.host}:${this.mailServer.port}/`; } @@ -69,7 +72,7 @@ if (Meteor.isServer) { }); Settings.after.update((userId, doc, fieldNames) => { // assign new values to mail-from & MAIL_URL in environment - if (_.contains(fieldNames, 'mailServer')) { + if (_.contains(fieldNames, 'mailServer') && _.contains(fieldNames, 'host')) { if (!doc.mailServer.username && !doc.mailServer.password) { process.env.MAIL_URL = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`; } else { @@ -97,12 +100,14 @@ if (Meteor.isServer) { url: FlowRouter.url('sign-up'), }; const lang = author.getLanguage(); - Email.send({ - to: icode.email, - from: Accounts.emailTemplates.from, - subject: TAPi18n.__('email-invite-register-subject', params, lang), - text: TAPi18n.__('email-invite-register-text', params, lang), - }); + if (Settings.findOne().mailUrl()) { + Email.send({ + to: icode.email, + from: Accounts.emailTemplates.from, + subject: TAPi18n.__('email-invite-register-subject', params, lang), + text: TAPi18n.__('email-invite-register-text', params, lang), + }); + } } catch (e) { InvitationCodes.remove(_id); throw new Meteor.Error('email-fail', e.message); |