Skip to content

Commit

Permalink
feat(new tool): Bounce Email Parser
Browse files Browse the repository at this point in the history
Parse SMTP bounce emails
  • Loading branch information
sharevb committed Sep 22, 2024
1 parent f5c4ab1 commit fdb4bd7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
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

0 comments on commit fdb4bd7

Please sign in to comment.