summaryrefslogtreecommitdiffstats
path: root/models/settings.js
diff options
context:
space:
mode:
authornztqa <nztqa@users.noreply.github.com>2017-11-27 16:44:19 +0900
committernztqa <nztqa@users.noreply.github.com>2017-11-27 16:44:19 +0900
commitdffe3d5ade15582ec71714031509a314a2616667 (patch)
treeefb1219939785e901afb312cb49e4fe7ae008fe4 /models/settings.js
parent33b76228975aecdba827f5e41cf3e9d4f2949aa9 (diff)
downloadwekan-dffe3d5ade15582ec71714031509a314a2616667.tar.gz
wekan-dffe3d5ade15582ec71714031509a314a2616667.tar.bz2
wekan-dffe3d5ade15582ec71714031509a314a2616667.zip
Add test SMTP settings
Diffstat (limited to 'models/settings.js')
-rw-r--r--models/settings.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/models/settings.js b/models/settings.js
index a02bb3fb..a05f2272 100644
--- a/models/settings.js
+++ b/models/settings.js
@@ -141,5 +141,30 @@ if (Meteor.isServer) {
}
});
},
+
+ sendSMTPTestEmail() {
+ if (!Meteor.userId()) {
+ throw new Meteor.Error('error-invalid-user', 'Invalid user');
+ }
+ const user = Meteor.user();
+ if (!user.emails && !user.emails[0] && user.emails[0].address) {
+ throw new Meteor.Error('error-invalid-email', 'Invalid email');
+ }
+ this.unblock();
+ try {
+ Email.send({
+ to: user.emails[0].address,
+ from: Accounts.emailTemplates.from,
+ subject: 'SMTP Test Email From Wekan',
+ text: 'You have successfully sent an email',
+ });
+ } catch ({message}) {
+ throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${ message }`, message);
+ }
+ return {
+ message: 'email-sent',
+ email: user.emails[0].address,
+ };
+ },
});
}