mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +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
|
|
@ -17,12 +17,17 @@ AccountsTemplates.addFields([{
|
||||||
template: 'invitationCode',
|
template: 'invitationCode',
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
let sendVerificationEmail = false;
|
||||||
|
if (process.env.MAIL_URL) {
|
||||||
|
sendVerificationEmail = true;
|
||||||
|
}
|
||||||
|
|
||||||
AccountsTemplates.configure({
|
AccountsTemplates.configure({
|
||||||
defaultLayout: 'userFormsLayout',
|
defaultLayout: 'userFormsLayout',
|
||||||
defaultContentRegion: 'content',
|
defaultContentRegion: 'content',
|
||||||
confirmPassword: false,
|
confirmPassword: false,
|
||||||
enablePasswordChange: true,
|
enablePasswordChange: true,
|
||||||
sendVerificationEmail: true,
|
sendVerificationEmail,
|
||||||
showForgotPasswordLink: true,
|
showForgotPasswordLink: true,
|
||||||
onLogoutHook() {
|
onLogoutHook() {
|
||||||
const homePage = 'home';
|
const homePage = 'home';
|
||||||
|
|
@ -69,4 +74,3 @@ if (Meteor.isServer) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ Settings.attachSchema(new SimpleSchema({
|
||||||
}));
|
}));
|
||||||
Settings.helpers({
|
Settings.helpers({
|
||||||
mailUrl () {
|
mailUrl () {
|
||||||
|
if (!this.mailServer.host) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!this.mailServer.username && !this.mailServer.password) {
|
if (!this.mailServer.username && !this.mailServer.password) {
|
||||||
return `smtp://${this.mailServer.host}:${this.mailServer.port}/`;
|
return `smtp://${this.mailServer.host}:${this.mailServer.port}/`;
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +72,7 @@ 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')) {
|
if (_.contains(fieldNames, 'mailServer') && _.contains(fieldNames, 'host')) {
|
||||||
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 = `smtp://${doc.mailServer.host}:${doc.mailServer.port}/`;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -97,12 +100,14 @@ if (Meteor.isServer) {
|
||||||
url: FlowRouter.url('sign-up'),
|
url: FlowRouter.url('sign-up'),
|
||||||
};
|
};
|
||||||
const lang = author.getLanguage();
|
const lang = author.getLanguage();
|
||||||
Email.send({
|
if (Settings.findOne().mailUrl()) {
|
||||||
to: icode.email,
|
Email.send({
|
||||||
from: Accounts.emailTemplates.from,
|
to: icode.email,
|
||||||
subject: TAPi18n.__('email-invite-register-subject', params, lang),
|
from: Accounts.emailTemplates.from,
|
||||||
text: TAPi18n.__('email-invite-register-text', params, lang),
|
subject: TAPi18n.__('email-invite-register-subject', params, lang),
|
||||||
});
|
text: TAPi18n.__('email-invite-register-text', params, lang),
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Meteor.Error('email-fail', e.message);
|
throw new Meteor.Error('email-fail', e.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -369,24 +369,25 @@ if (Meteor.isServer) {
|
||||||
board.addMember(user._id);
|
board.addMember(user._id);
|
||||||
user.addInvite(boardId);
|
user.addInvite(boardId);
|
||||||
|
|
||||||
try {
|
if (Settings.findOne().mailUrl()) {
|
||||||
const params = {
|
try {
|
||||||
user: user.username,
|
const params = {
|
||||||
inviter: inviter.username,
|
user: user.username,
|
||||||
board: board.title,
|
inviter: inviter.username,
|
||||||
url: board.absoluteUrl(),
|
board: board.title,
|
||||||
};
|
url: board.absoluteUrl(),
|
||||||
const lang = user.getLanguage();
|
};
|
||||||
Email.send({
|
const lang = user.getLanguage();
|
||||||
to: user.emails[0].address.toLowerCase(),
|
Email.send({
|
||||||
from: Accounts.emailTemplates.from,
|
to: user.emails[0].address.toLowerCase(),
|
||||||
subject: TAPi18n.__('email-invite-subject', params, lang),
|
from: Accounts.emailTemplates.from,
|
||||||
text: TAPi18n.__('email-invite-text', params, lang),
|
subject: TAPi18n.__('email-invite-subject', params, lang),
|
||||||
});
|
text: TAPi18n.__('email-invite-text', params, lang),
|
||||||
} catch (e) {
|
});
|
||||||
throw new Meteor.Error('email-fail', e.message);
|
} catch (e) {
|
||||||
|
throw new Meteor.Error('email-fail', e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { username: user.username, email: user.emails[0].address };
|
return { username: user.username, email: user.emails[0].address };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -502,4 +503,3 @@ if (Meteor.isServer) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,17 @@ Meteor.startup(() => {
|
||||||
const text = texts.join('\n\n');
|
const text = texts.join('\n\n');
|
||||||
user.clearEmailBuffer();
|
user.clearEmailBuffer();
|
||||||
|
|
||||||
try {
|
if (Settings.findOne().mailUrl()) {
|
||||||
Email.send({
|
try {
|
||||||
to: user.emails[0].address.toLowerCase(),
|
Email.send({
|
||||||
from: Accounts.emailTemplates.from,
|
to: user.emails[0].address.toLowerCase(),
|
||||||
subject: TAPi18n.__('act-activity-notify', {}, user.getLanguage()),
|
from: Accounts.emailTemplates.from,
|
||||||
text,
|
subject: TAPi18n.__('act-activity-notify', {}, user.getLanguage()),
|
||||||
});
|
text,
|
||||||
} catch (e) {
|
});
|
||||||
return;
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 30000);
|
}, 30000);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue