Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(new tool): Bounce Email Parser #1305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/tools/bounce-parser/bounce-parser.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script setup lang="ts">
import EmailBounceParse from 'email-bounce-parser';

Check failure on line 2 in src/tools/bounce-parser/bounce-parser.vue

View workflow job for this annotation

GitHub Actions / ci

Cannot find module 'email-bounce-parser' or its corresponding type declarations.

const emailContent = ref('');

const parsedBounce = computed(() => {
try {
return new EmailBounceParse().read(emailContent.value);
}
catch (e: any) {
return { parsingError: e.toString() };
}
});
</script>

<template>
<div style="max-width: 600px;">
<c-card title="Input" mb-2>
<c-input-text
v-model:value="emailContent"
label="Bounce Email Textual Content"
multiline
placeholder="Put your email text content here..."
rows="15"
mb-2
/>
</c-card>

<c-card v-if="parsedBounce && emailContent" title="Output">
<n-p v-if="parsedBounce.bounce" style="color: green">
This mail is a bounce email
</n-p>
<n-p v-if="!parsedBounce.bounce" style="color: red">
This mail is NOT a bounce email
</n-p>
<c-alert v-if="!parsedBounce.parsingError">
{{ parsedBounce.parsingError }}
</c-alert>
<input-copyable v-if="parsedBounce.recipient" label="Recipient" :value="parsedBounce.recipient" />
<input-copyable v-if="parsedBounce.server?.hostname" label="Server (Host)" :value="parsedBounce.server?.hostname" />
<input-copyable v-if="parsedBounce.server?.ip" label="Server (IP)" :value="parsedBounce.server?.ip" />
<input-copyable v-if="parsedBounce.server?.port" label="Server (Port)" :value="parsedBounce.server?.port" />
<input-copyable v-if="parsedBounce.command" label="Recipient" :value="parsedBounce.command" />
<c-card v-if="parsedBounce.data" title="Details" mb-2>
<textarea-copyable :value="JSON.stringify(parsedBounce.data, null, 2)" />
</c-card>
<c-card v-if="parsedBounce.email?.error" title="Raw Error" mb-2>
<textarea-copyable :value="parsedBounce.email?.error" />
</c-card>
</c-card>
</div>
</template>
12 changes: 12 additions & 0 deletions src/tools/bounce-parser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Mailbox } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'Bounce Email Parser',
path: '/bounce-parser',
description: 'Parse SMTP Bounce Emails',
keywords: ['bounce', 'email', 'smtp', 'parser'],
component: () => import('./bounce-parser.vue'),
icon: Mailbox,
createdAt: new Date('2024-08-15'),
});
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as bounceParser } from './bounce-parser';

import { tool as asciiTextDrawer } from './ascii-text-drawer';

Expand Down Expand Up @@ -137,6 +138,7 @@ export const toolsByCategory: ToolCategory[] = [
httpStatusCodes,
jsonDiff,
safelinkDecoder,
bounceParser,
],
},
{
Expand Down
Loading