mirror of
https://github.com/wekan/wekan.git
synced 2026-01-31 13:45:17 +01:00
Don't send emails if missing smtp host
This commit is contained in:
parent
feafc46bb5
commit
5db786e2dd
4 changed files with 47 additions and 36 deletions
|
|
@ -35,6 +35,9 @@ Settings.attachSchema(new SimpleSchema({
|
|||
}));
|
||||
Settings.helpers({
|
||||
mailUrl () {
|
||||
if (!this.mailServer.host) {
|
||||
return null;
|
||||
}
|
||||
if (!this.mailServer.username && !this.mailServer.password) {
|
||||
return `smtp://${this.mailServer.host}:${this.mailServer.port}/`;
|
||||
}
|
||||
|
|
@ -69,7 +72,7 @@ if (Meteor.isServer) {
|
|||
});
|
||||
Settings.after.update((userId, doc, fieldNames) => {
|
||||
// assign new values to mail-from & MAIL_URL in environment
|
||||
if (_.contains(fieldNames, 'mailServer')) {
|
||||
if (_.contains(fieldNames, 'mailServer') && _.contains(fieldNames, 'host')) {
|
||||
if (!doc.mailServer.username && !doc.mailServer.password) {
|
||||
process.env.MAIL_URL = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`;
|
||||
} else {
|
||||
|
|
@ -97,12 +100,14 @@ if (Meteor.isServer) {
|
|||
url: FlowRouter.url('sign-up'),
|
||||
};
|
||||
const lang = author.getLanguage();
|
||||
Email.send({
|
||||
to: icode.email,
|
||||
from: Accounts.emailTemplates.from,
|
||||
subject: TAPi18n.__('email-invite-register-subject', params, lang),
|
||||
text: TAPi18n.__('email-invite-register-text', params, lang),
|
||||
});
|
||||
if (Settings.findOne().mailUrl()) {
|
||||
Email.send({
|
||||
to: icode.email,
|
||||
from: Accounts.emailTemplates.from,
|
||||
subject: TAPi18n.__('email-invite-register-subject', params, lang),
|
||||
text: TAPi18n.__('email-invite-register-text', params, lang),
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Meteor.Error('email-fail', e.message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,24 +369,25 @@ if (Meteor.isServer) {
|
|||
board.addMember(user._id);
|
||||
user.addInvite(boardId);
|
||||
|
||||
try {
|
||||
const params = {
|
||||
user: user.username,
|
||||
inviter: inviter.username,
|
||||
board: board.title,
|
||||
url: board.absoluteUrl(),
|
||||
};
|
||||
const lang = user.getLanguage();
|
||||
Email.send({
|
||||
to: user.emails[0].address.toLowerCase(),
|
||||
from: Accounts.emailTemplates.from,
|
||||
subject: TAPi18n.__('email-invite-subject', params, lang),
|
||||
text: TAPi18n.__('email-invite-text', params, lang),
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Meteor.Error('email-fail', e.message);
|
||||
if (Settings.findOne().mailUrl()) {
|
||||
try {
|
||||
const params = {
|
||||
user: user.username,
|
||||
inviter: inviter.username,
|
||||
board: board.title,
|
||||
url: board.absoluteUrl(),
|
||||
};
|
||||
const lang = user.getLanguage();
|
||||
Email.send({
|
||||
to: user.emails[0].address.toLowerCase(),
|
||||
from: Accounts.emailTemplates.from,
|
||||
subject: TAPi18n.__('email-invite-subject', params, lang),
|
||||
text: TAPi18n.__('email-invite-text', params, lang),
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Meteor.Error('email-fail', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return { username: user.username, email: user.emails[0].address };
|
||||
},
|
||||
});
|
||||
|
|
@ -502,4 +503,3 @@ if (Meteor.isServer) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue