diff --git a/plugins/setting-resources/src/components/MailboxEditorModal.svelte b/plugins/setting-resources/src/components/MailboxEditorModal.svelte index fd8f803c4e..c8be7b38ac 100644 --- a/plugins/setting-resources/src/components/MailboxEditorModal.svelte +++ b/plugins/setting-resources/src/components/MailboxEditorModal.svelte @@ -38,7 +38,7 @@ function validateName (name: string): boolean { const n = name.trim() - return n.length >= mailboxOptions.minNameLength && n.length <= mailboxOptions.maxNameLength + return n.length >= mailboxOptions.minNameLength && n.length <= mailboxOptions.maxNameLength && !name.includes('+') } async function createMailbox (): Promise { diff --git a/services/mail/pod-inbound-mail/package.json b/services/mail/pod-inbound-mail/package.json index b1fde8781c..f8f5d00226 100644 --- a/services/mail/pod-inbound-mail/package.json +++ b/services/mail/pod-inbound-mail/package.json @@ -17,11 +17,12 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "node ../../../common/scripts/esbuild.js --external=ws", + "bundle": "node ../../../common/scripts/esbuild.js --external=ws --external=jsdom", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/inbound-mail", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/inbound-mail staging", "docker:abuild": "docker build -t hardcoreeng/inbound-mail . --platform=linux/arm64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/inbound-mail", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/inbound-mail", + "run-bundle": "rushx bundle --to @hcengineering/pod-inbound-mail && cross-env NODE_ENV=production node --inspect bundle/bundle.js", "run-local": "ts-node src/index.ts", "format": "format src", "_phase:build": "compile transpile src", @@ -37,6 +38,7 @@ "@types/jest": "^29.5.5", "@types/node": "~20.11.16", "@types/turndown": "^5.0.5", + "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "cross-env": "~7.0.3", @@ -66,7 +68,6 @@ "@hcengineering/mail": "^0.6.0", "@hcengineering/server-core": "^0.6.1", "@hcengineering/server-storage": "^0.6.0", - "@types/uuid": "^8.3.1", "cors": "^2.8.5", "dotenv": "~16.0.0", "eml-parse-js": "^1.2.0-beta.0", diff --git a/services/mail/pod-inbound-mail/src/handlerMta.ts b/services/mail/pod-inbound-mail/src/handlerMta.ts index 30a5e016c2..0234a9d423 100644 --- a/services/mail/pod-inbound-mail/src/handlerMta.ts +++ b/services/mail/pod-inbound-mail/src/handlerMta.ts @@ -56,7 +56,7 @@ export async function handleMtaHook (req: Request, res: Response, ctx: MeasureCo from.name = extractContactName(ctx, fromHeader) } - const tos = mta.envelope.to.map((to) => ({ address: to.address, name: '' })) + const tos = mta.envelope.to.map((to) => ({ address: stripTags(to.address), name: '' })) const toHeader = mta.message.headers.find((header) => header[0] === 'To')?.[1] if (toHeader !== undefined) { for (const part of toHeader.split(',')) { @@ -192,3 +192,13 @@ function decodeMimeWord (ctx: MeasureContext, text: string): string { } }) } + +function stripTags (email: string): string { + const [name, domain] = email.split('@') + const tagStart = name.indexOf('+') + if (tagStart === -1) { + return email + } + const clearName = name.substring(0, tagStart) + return `${clearName}@${domain}` +}