diff options
Diffstat (limited to 'models/settings.js')
-rw-r--r-- | models/settings.js | 25 |
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, + }; + }, }); } |