|
@@ -20,6 +20,10 @@ Settings.attachSchema(new SimpleSchema({
|
|
type: String,
|
|
type: String,
|
|
optional: true,
|
|
optional: true,
|
|
},
|
|
},
|
|
|
|
+ 'mailServer.enableTLS': {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ optional: true,
|
|
|
|
+ },
|
|
'mailServer.from': {
|
|
'mailServer.from': {
|
|
type: String,
|
|
type: String,
|
|
optional: true,
|
|
optional: true,
|
|
@@ -38,10 +42,11 @@ Settings.helpers({
|
|
if (!this.mailServer.host) {
|
|
if (!this.mailServer.host) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+ const protocol = this.mailServer.enableTLS ? 'smtps://' : 'smtp://';
|
|
if (!this.mailServer.username && !this.mailServer.password) {
|
|
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({
|
|
Settings.allow({
|
|
@@ -62,7 +67,7 @@ if (Meteor.isServer) {
|
|
if(!setting){
|
|
if(!setting){
|
|
const now = new Date();
|
|
const now = new Date();
|
|
const defaultSetting = {disableRegistration: false, mailServer: {
|
|
const defaultSetting = {disableRegistration: false, mailServer: {
|
|
- username: '', password:'', host: '', port:'', from: '',
|
|
|
|
|
|
+ username: '', password: '', host: '', port: '', enableTLS: false, from: '',
|
|
}, createdAt: now, modifiedAt: now};
|
|
}, createdAt: now, modifiedAt: now};
|
|
Settings.insert(defaultSetting);
|
|
Settings.insert(defaultSetting);
|
|
}
|
|
}
|
|
@@ -72,11 +77,12 @@ if (Meteor.isServer) {
|
|
});
|
|
});
|
|
Settings.after.update((userId, doc, fieldNames) => {
|
|
Settings.after.update((userId, doc, fieldNames) => {
|
|
// assign new values to mail-from & MAIL_URL in environment
|
|
// 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) {
|
|
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 {
|
|
} 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;
|
|
Accounts.emailTemplates.from = doc.mailServer.from;
|
|
}
|
|
}
|