fix: improve the email domain validation in the contact API
Some checks failed
Deploy Next.js application / deploy (push) Failing after 8s
Some checks failed
Deploy Next.js application / deploy (push) Failing after 8s
This commit is contained in:
parent
7288e380ee
commit
6859bc0ba2
1 changed files with 18 additions and 1 deletions
|
@ -136,7 +136,24 @@ export async function POST(req: NextRequest) {
|
||||||
let isEmailHostValid = false;
|
let isEmailHostValid = false;
|
||||||
try {
|
try {
|
||||||
const mxRecords = await dns.resolveMx(emailDomain);
|
const mxRecords = await dns.resolveMx(emailDomain);
|
||||||
if (mxRecords.length > 0) isEmailHostValid = true;
|
if (mxRecords.length > 0) {
|
||||||
|
for (let i = 0; i < mxRecords.length; i++) {
|
||||||
|
try {
|
||||||
|
const aRecords = await dns.resolve4(mxRecords[i].exchange);
|
||||||
|
if (aRecords.length > 0) {
|
||||||
|
isEmailHostValid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {}
|
||||||
|
try {
|
||||||
|
const aaaaRecords = await dns.resolve6(mxRecords[i].exchange);
|
||||||
|
if (aaaaRecords.length > 0) {
|
||||||
|
isEmailHostValid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
if (!isEmailHostValid) {
|
if (!isEmailHostValid) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|
Loading…
Reference in a new issue