mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Fix SMTP port lost after upgrade. STMP settings are made only with environment variables on non-Sandstorm platforms.
Note: Sending email on Sandstorm Wekan does not work yet. Thanks to jrsupplee and xet7 ! Fixes #3529, Fixes #3016, Fixes #2375, Fixes #2598, Fixes wekan/wekan-snap#78
This commit is contained in:
parent
8f5089fd46
commit
65b8220fe5
2 changed files with 65 additions and 50 deletions
|
@ -80,39 +80,40 @@ template(name="general")
|
||||||
|
|
||||||
template(name='email')
|
template(name='email')
|
||||||
ul#email-setting.setting-detail
|
ul#email-setting.setting-detail
|
||||||
li.smtp-form
|
if isSandstorm
|
||||||
.title {{_ 'smtp-host'}}
|
li.smtp-form
|
||||||
.description {{_ 'smtp-host-description'}}
|
.title {{_ 'smtp-host'}}
|
||||||
.form-group
|
.description {{_ 'smtp-host-description'}}
|
||||||
input.wekan-form-control#mail-server-host(type="text", placeholder="smtp.domain.com" value="{{currentSetting.mailServer.host}}")
|
.form-group
|
||||||
li.smtp-form
|
input.wekan-form-control#mail-server-host(type="text", placeholder="smtp.domain.com" value="{{currentSetting.mailServer.host}}")
|
||||||
.title {{_ 'smtp-port'}}
|
li.smtp-form
|
||||||
.description {{_ 'smtp-port-description'}}
|
.title {{_ 'smtp-port'}}
|
||||||
.form-group
|
.description {{_ 'smtp-port-description'}}
|
||||||
input.wekan-form-control#mail-server-port(type="text", placeholder="25" value="{{currentSetting.mailServer.port}}")
|
.form-group
|
||||||
li.smtp-form
|
input.wekan-form-control#mail-server-port(type="text", placeholder="25" value="{{currentSetting.mailServer.port}}")
|
||||||
.title {{_ 'smtp-username'}}
|
li.smtp-form
|
||||||
.form-group
|
.title {{_ 'smtp-username'}}
|
||||||
input.wekan-form-control#mail-server-username(type="text", placeholder="{{_ 'username'}}" value="{{currentSetting.mailServer.username}}")
|
.form-group
|
||||||
li.smtp-form
|
input.wekan-form-control#mail-server-username(type="text", placeholder="{{_ 'username'}}" value="{{currentSetting.mailServer.username}}")
|
||||||
.title {{_ 'smtp-password'}}
|
li.smtp-form
|
||||||
.form-group
|
.title {{_ 'smtp-password'}}
|
||||||
input.wekan-form-control#mail-server-password(type="password", placeholder="{{_ 'password'}}" value="")
|
.form-group
|
||||||
li.smtp-form
|
input.wekan-form-control#mail-server-password(type="password", placeholder="{{_ 'password'}}" value="")
|
||||||
.title {{_ 'smtp-tls'}}
|
li.smtp-form
|
||||||
.form-group
|
.title {{_ 'smtp-tls'}}
|
||||||
a.flex.js-toggle-tls
|
.form-group
|
||||||
.materialCheckBox#mail-server-tls(class="{{#if currentSetting.mailServer.enableTLS}}is-checked{{/if}}")
|
a.flex.js-toggle-tls
|
||||||
|
.materialCheckBox#mail-server-tls(class="{{#if currentSetting.mailServer.enableTLS}}is-checked{{/if}}")
|
||||||
|
|
||||||
span {{_ 'smtp-tls-description'}}
|
span {{_ 'smtp-tls-description'}}
|
||||||
|
|
||||||
li.smtp-form
|
li.smtp-form
|
||||||
.title {{_ 'send-from'}}
|
.title {{_ 'send-from'}}
|
||||||
.form-group
|
.form-group
|
||||||
input.wekan-form-control#mail-server-from(type="email", placeholder="no-reply@domain.com" value="{{currentSetting.mailServer.from}}")
|
input.wekan-form-control#mail-server-from(type="email", placeholder="no-reply@domain.com" value="{{currentSetting.mailServer.from}}")
|
||||||
|
|
||||||
li
|
li
|
||||||
button.js-save.primary {{_ 'save'}}
|
button.js-save.primary {{_ 'save'}}
|
||||||
|
|
||||||
li
|
li
|
||||||
button.js-send-smtp-test-email.primary {{_ 'send-smtp-test'}}
|
button.js-send-smtp-test-email.primary {{_ 'send-smtp-test'}}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
// Sandstorm context is detected using the METEOR_SETTINGS environment variable
|
||||||
|
// in the package definition.
|
||||||
|
const isSandstorm =
|
||||||
|
Meteor.settings && Meteor.settings.public && Meteor.settings.public.sandstorm;
|
||||||
|
|
||||||
Settings = new Mongo.Collection('settings');
|
Settings = new Mongo.Collection('settings');
|
||||||
|
|
||||||
Settings.attachSchema(
|
Settings.attachSchema(
|
||||||
|
@ -144,29 +149,38 @@ if (Meteor.isServer) {
|
||||||
};
|
};
|
||||||
Settings.insert(defaultSetting);
|
Settings.insert(defaultSetting);
|
||||||
}
|
}
|
||||||
const newSetting = Settings.findOne();
|
if (isSandstorm) {
|
||||||
if (!process.env.MAIL_URL && newSetting.mailUrl())
|
// At Sandstorm, Admin Panel has SMTP settings
|
||||||
|
const newSetting = Settings.findOne();
|
||||||
|
if (!process.env.MAIL_URL && newSetting.mailUrl())
|
||||||
process.env.MAIL_URL = newSetting.mailUrl();
|
process.env.MAIL_URL = newSetting.mailUrl();
|
||||||
Accounts.emailTemplates.from = process.env.MAIL_FROM
|
Accounts.emailTemplates.from = process.env.MAIL_FROM
|
||||||
? process.env.MAIL_FROM
|
? process.env.MAIL_FROM
|
||||||
: newSetting.mailServer.from;
|
: newSetting.mailServer.from;
|
||||||
});
|
} else {
|
||||||
Settings.after.update((userId, doc, fieldNames) => {
|
// Not running on Sandstorm, so using environment variables
|
||||||
// assign new values to mail-from & MAIL_URL in environment
|
Accounts.emailTemplates.from = process.env.MAIL_FROM;
|
||||||
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 = `${protocol}${doc.mailServer.host}:${doc.mailServer.port}/`;
|
|
||||||
} else {
|
|
||||||
process.env.MAIL_URL = `${protocol}${
|
|
||||||
doc.mailServer.username
|
|
||||||
}:${encodeURIComponent(doc.mailServer.password)}@${
|
|
||||||
doc.mailServer.host
|
|
||||||
}:${doc.mailServer.port}/`;
|
|
||||||
}
|
|
||||||
Accounts.emailTemplates.from = doc.mailServer.from;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (isSandstorm) {
|
||||||
|
// At Sandstorm Wekan Admin Panel, save SMTP settings.
|
||||||
|
Settings.after.update((userId, doc, fieldNames) => {
|
||||||
|
// assign new values to mail-from & MAIL_URL in environment
|
||||||
|
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 = `${protocol}${doc.mailServer.host}:${doc.mailServer.port}/`;
|
||||||
|
} else {
|
||||||
|
process.env.MAIL_URL = `${protocol}${
|
||||||
|
doc.mailServer.username
|
||||||
|
}:${encodeURIComponent(doc.mailServer.password)}@${
|
||||||
|
doc.mailServer.host
|
||||||
|
}:${doc.mailServer.port}/`;
|
||||||
|
}
|
||||||
|
Accounts.emailTemplates.from = doc.mailServer.from;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getRandomNum(min, max) {
|
function getRandomNum(min, max) {
|
||||||
const range = max - min;
|
const range = max - min;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue