UNPKG

@proca/widget

Version:

Proca is an open-source campaign toolkit designed to empower activists and organisations in their digital advocacy efforts. It provides a flexible and customisable platform for creating and managing online petitions, email campaigns, and other forms of di

27 lines (23 loc) 673 B
const getDomain = email => { const parts = email.split("@"); if (parts.length !== 2) return false; return parts[1]; }; // return name of the main domain of the MX record if found, false if no mx record const checkMail = async email => { if (!email) return false; const domain = getDomain(email); if (!domain) return false; try { const response = await fetch( `${process.env.REACT_APP_CHECKMAIL_API_URL}/${domain}` ); const r = await response.json(); return r; } catch (e) { console.log(e); return ""; // don't block submission if the service isn't reachable } }; export default checkMail; export { getDomain, checkMail };