summaryrefslogtreecommitdiffstats
path: root/models/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/settings.js')
-rw-r--r--models/settings.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/models/settings.js b/models/settings.js
index 0c2da4d3..e5b9783a 100644
--- a/models/settings.js
+++ b/models/settings.js
@@ -20,6 +20,10 @@ Settings.attachSchema(new SimpleSchema({
type: String,
optional: true,
},
+ 'mailServer.enableTLS': {
+ type: Boolean,
+ optional: true,
+ },
'mailServer.from': {
type: String,
optional: true,
@@ -38,10 +42,11 @@ Settings.helpers({
if (!this.mailServer.host) {
return null;
}
+ const protocol = this.mailServer.enableTLS ? 'smtps://' : 'smtp://';
if (!this.mailServer.username && !this.mailServer.password) {
- return `smtp://${this.mailServer.host}:${this.mailServer.port}/`;
+ return `${protocol}${this.mailServer.host}:${this.mailServer.port}/`;
}
- return `smtp://${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`;
+ return `${protocol}${this.mailServer.username}:${this.mailServer.password}@${this.mailServer.host}:${this.mailServer.port}/`;
},
});
Settings.allow({
@@ -62,7 +67,7 @@ if (Meteor.isServer) {
if(!setting){
const now = new Date();
const defaultSetting = {disableRegistration: false, mailServer: {
- username: '', password:'', host: '', port:'', from: '',
+ username: '', password: '', host: '', port: '', enableTLS: false, from: '',
}, createdAt: now, modifiedAt: now};
Settings.insert(defaultSetting);
}
@@ -72,11 +77,12 @@ if (Meteor.isServer) {
});
Settings.after.update((userId, doc, fieldNames) => {
// assign new values to mail-from & MAIL_URL in environment
- if (_.contains(fieldNames, 'mailServer') && _.contains(fieldNames, 'host')) {
+ if (_.contains(fieldNames, 'mailServer') && doc.mailServer.host) {
+ const protocol = doc.mailServer.enableTLS ? 'smtps://' : 'smtp://';
if (!doc.mailServer.username && !doc.mailServer.password) {
- process.env.MAIL_URL = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`;
+ process.env.MAIL_URL = `${protocol}${doc.mailServer.host}:${doc.mailServer.port}/`;
} else {
- process.env.MAIL_URL = `smtp://${doc.mailServer.username}:${doc.mailServer.password}@${doc.mailServer.host}:${doc.mailServer.port}/`;
+ process.env.MAIL_URL = `${protocol}${doc.mailServer.username}:${doc.mailServer.password}@${doc.mailServer.host}:${doc.mailServer.port}/`;
}
Accounts.emailTemplates.from = doc.mailServer.from;
}