diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-11-28 08:49:44 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-11-28 08:49:44 +0200 |
commit | c048ce89f1c9e26c6973f7f18a4dd6871e57928e (patch) | |
tree | 91bebe05094003913c178f36cfb237566f3b8576 /models | |
parent | 162b15c0cdba99c406f41a80a431f2b99f4ff027 (diff) | |
parent | 44559b52a6d45df57f1ca8eeaae25d55eb7e8148 (diff) | |
download | wekan-c048ce89f1c9e26c6973f7f18a4dd6871e57928e.tar.gz wekan-c048ce89f1c9e26c6973f7f18a4dd6871e57928e.tar.bz2 wekan-c048ce89f1c9e26c6973f7f18a4dd6871e57928e.zip |
Merge branch 'improve-smtp-testing' of https://github.com/nztqa/wekan into nztqa-improve-smtp-testing
Diffstat (limited to 'models')
-rw-r--r-- | models/settings.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/models/settings.js b/models/settings.js index a02bb3fb..34f693d9 100644 --- a/models/settings.js +++ b/models/settings.js @@ -141,5 +141,31 @@ if (Meteor.isServer) { } }); }, + + sendSMTPTestEmail() { + if (!Meteor.userId()) { + throw new Meteor.Error('invalid-user'); + } + const user = Meteor.user(); + if (!user.emails && !user.emails[0] && user.emails[0].address) { + throw new Meteor.Error('email-invalid'); + } + this.unblock(); + const lang = user.getLanguage(); + try { + Email.send({ + to: user.emails[0].address, + from: Accounts.emailTemplates.from, + subject: TAPi18n.__('email-smtp-test-subject', {lng: lang}), + text: TAPi18n.__('email-smtp-test-text', {lng: lang}), + }); + } catch ({message}) { + throw new Meteor.Error('email-fail', `${TAPi18n.__('email-fail-text', {lng: lang})}: ${ message }`, message); + } + return { + message: 'email-sent', + email: user.emails[0].address, + }; + }, }); } |