mirror of
https://github.com/schroinerxy/cloud-mail.git
synced 2026-06-21 19:35:50 +08:00
邮件拒收退回
This commit is contained in:
@@ -35,6 +35,7 @@ export async function email(message, env, ctx) {
|
||||
} = await settingService.query({ env });
|
||||
|
||||
if (receive === settingConst.receive.CLOSE) {
|
||||
message.setReject('Service suspended');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ export async function email(message, env, ctx) {
|
||||
const account = await accountService.selectByEmailIncludeDel({ env: env }, message.to);
|
||||
|
||||
if (!account && noRecipient === settingConst.noRecipient.CLOSE) {
|
||||
message.setReject('Recipient not found');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ export async function email(message, env, ctx) {
|
||||
let { banEmail, banEmailType, availDomain } = await roleService.selectByUserId({ env: env }, account.userId);
|
||||
|
||||
if(!roleService.hasAvailDomainPerm(availDomain, message.to)) {
|
||||
message.setReject('Mailbox disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +71,9 @@ export async function email(message, env, ctx) {
|
||||
|
||||
|
||||
if (banEmail.includes('*')) {
|
||||
return;
|
||||
|
||||
if (!banEmailHandler(banEmailType,message,email)) return
|
||||
|
||||
}
|
||||
|
||||
for (const item of banEmail) {
|
||||
@@ -80,13 +85,7 @@ export async function email(message, env, ctx) {
|
||||
|
||||
if (banDomain === receiveDomain) {
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.ALL) return;
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.CONTENT) {
|
||||
email.html = 'The content has been deleted';
|
||||
email.text = 'The content has been deleted';
|
||||
email.attachments = [];
|
||||
}
|
||||
if (!banEmailHandler(banEmailType,message,email)) return
|
||||
|
||||
}
|
||||
|
||||
@@ -94,13 +93,7 @@ export async function email(message, env, ctx) {
|
||||
|
||||
if (item.toLowerCase() === email.from.address.toLowerCase()) {
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.ALL) return;
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.CONTENT) {
|
||||
email.html = 'The content has been deleted';
|
||||
email.text = 'The content has been deleted';
|
||||
email.attachments = [];
|
||||
}
|
||||
if (!banEmailHandler(banEmailType,message,email)) return
|
||||
|
||||
}
|
||||
|
||||
@@ -227,3 +220,20 @@ ${params.text || emailUtils.htmlToText(params.content) || ''}
|
||||
console.error('邮件接收异常: ', e);
|
||||
}
|
||||
}
|
||||
|
||||
function banEmailHandler(banEmailType,message,email) {
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.ALL) {
|
||||
message.setReject('Mailbox disabled');
|
||||
return false
|
||||
}
|
||||
|
||||
if (banEmailType === roleConst.banEmailType.CONTENT) {
|
||||
email.html = 'The content has been deleted';
|
||||
email.text = 'The content has been deleted';
|
||||
email.attachments = [];
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user