Skip to content

Mail Test #2277

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

Merged
merged 2 commits into from
Mar 29, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ const _nav = [
name: 'Mailbox Restores',
to: '/email/tools/mailbox-restores',
},
{
component: CNavItem,
name: 'Mail Test',
to: '/email/tools/mail-test',
},
],
},
{
Expand Down
7 changes: 7 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import MailTest from 'src/views/email-exchange/tools/MailTest'

const Home = React.lazy(() => import('src/views/home/Home'))
const Logs = React.lazy(() => import('src/views/cipp/Logs'))
Expand Down Expand Up @@ -247,6 +248,7 @@ const MailboxRestoreWizard = React.lazy(() =>
import('src/views/email-exchange/tools/MailboxRestoreWizard'),
)
const MailboxRestores = React.lazy(() => import('src/views/email-exchange/tools/MailboxRestores'))
const Mailtest = React.lazy(() => import('src/views/email-exchange/tools/MailTest'))

const routes = [
// { path: '/', exact: true, name: 'Home' },
Expand Down Expand Up @@ -611,6 +613,11 @@ const routes = [
name: 'Mailbox Restores',
component: MailboxRestores,
},
{
path: '/email/tools/mail-test',
name: 'Mail Test',
component: MailTest,
},
{
path: '/email/spamfilter/add-template',
name: 'Add Spamfilter Template',
Expand Down
101 changes: 101 additions & 0 deletions src/views/email-exchange/tools/MailTest.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React from 'react'
import { CippCallout, CippPageList } from 'src/components/layout'
import { cellBooleanFormatter, cellDateFormatter } from 'src/components/tables'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import { useGenericGetRequestQuery } from 'src/store/api/app'

const MailTest = () => {
const { data: config, isSuccess } = useGenericGetRequestQuery({
path: '/api/ExecMailTest',
params: { Action: 'CheckConfig' },
})

const columns = [
{
name: 'Received',
selector: (row) => row['Received'],
sortable: true,
exportSelector: 'Received',
cell: cellDateFormatter({ format: 'short' }),
},
{
name: 'From',
selector: (row) => row['From'],
sortable: true,
exportSelector: 'From',
cell: cellGenericFormatter(),
},
{
name: 'Subject',
selector: (row) => row['Subject'],
sortable: true,
exportSelector: 'Subject',
cell: cellGenericFormatter(),
},
{
name: 'SPF',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'spf')[0].Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'DKIM',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dkim')[0].Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'DMARC',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dmarc')[0].Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'Comp Auth',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'compauth')[0].Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'Auth Details',
selector: (row) => row['AuthResult'],
exportSelector: 'AuthResult',
cell: cellGenericFormatter(),
},
{
name: 'Headers',
selector: (row) => row['Headers'],
exportSelector: 'Headers',
cell: cellGenericFormatter(),
},
{
name: 'Open Message',
selector: (row) => row['Link'],
exportSelector: 'Link',
cell: cellGenericFormatter(),
},
]
return (
<div>
{isSuccess && (
<CippCallout color={config?.HasMailRead ? 'info' : 'warning'} dismissible={true}>
{config?.HasMailRead &&
'Mail Test Email: ' + config?.MailAddresses.filter((x) => x?.IsPrimary)[0]?.Address}
{config?.HasMailRead == false && 'Permission Check: ' + config?.Message}
</CippCallout>
)}
{isSuccess && config?.HasMailRead === true && (
<CippPageList
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
title="Mail Test"
tenantSelector={false}
datatable={{
tableProps: {},
keyField: 'id',
columns,
reportName: `MailTest`,
path: '/api/ExecMailTest',
}}
/>
)}
</div>
)
}

export default MailTest