generated from tpl/purs
fix: fuck
This commit is contained in:
parent
da860c8f39
commit
3d9aa86ffe
@ -1,35 +1,4 @@
|
|||||||
import { checkSyntax, checkMX, checkSMTP } from 'qed-mail'
|
import { checkEmail } from 'qed-mail'
|
||||||
|
|
||||||
const DEFAULT_RESULT = {
|
|
||||||
reachable: false,
|
|
||||||
|
|
||||||
syntax: { valid: false },
|
|
||||||
mx: { valid: false },
|
|
||||||
smtp: { valid: false },
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @type {(_: string) => Promise<import('qed-mail/src/types.js').Result>} */
|
|
||||||
async function checkEmail(email) {
|
|
||||||
const result = { email, ...DEFAULT_RESULT };
|
|
||||||
|
|
||||||
const syntax = checkSyntax(email);
|
|
||||||
if (!syntax.valid) {
|
|
||||||
return { ...result, syntax };
|
|
||||||
}
|
|
||||||
|
|
||||||
const mx = await checkMX(syntax.domain || '');
|
|
||||||
if (!mx.valid || !mx.mxRecords) {
|
|
||||||
return { ...result, syntax, mx };
|
|
||||||
}
|
|
||||||
|
|
||||||
const records = mx.mxRecords.sort((a, b) => a.priority - b.priority);
|
|
||||||
const smtp = await checkSMTP(email, records[0].exchange, 500);
|
|
||||||
if (!smtp.valid) {
|
|
||||||
return { ...result, syntax, mx, smtp };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { ...result, reachable: true, syntax, mx, smtp };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @type {(_: string) => () => Promise<import('qed-mail/src/types.js').Result>} */
|
/** @type {(_: string) => () => Promise<import('qed-mail/src/types.js').Result>} */
|
||||||
export const checkEmailImpl = s => () => checkEmail(s)
|
export const checkEmailImpl = s => () => checkEmail(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user