diff --git a/src/Effect.Email.js b/src/Effect.Email.js index 8eca8aa..444eda2 100644 --- a/src/Effect.Email.js +++ b/src/Effect.Email.js @@ -1,35 +1,4 @@ -import { checkSyntax, checkMX, checkSMTP } from 'qed-mail' - -const DEFAULT_RESULT = { - reachable: false, - - syntax: { valid: false }, - mx: { valid: false }, - smtp: { valid: false }, -}; - -/** @type {(_: string) => Promise} */ -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 }; -} +import { checkEmail } from 'qed-mail' /** @type {(_: string) => () => Promise} */ export const checkEmailImpl = s => () => checkEmail(s)