summaryrefslogtreecommitdiffstats
path: root/models/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/settings.js')
-rw-r--r--models/settings.js26
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,
+ };
+ },
});
}