Email Domain MX Validation: Fly + Fastify + Redis

Hey peeps, just thought I would share a little endpoint I deployed on Fly today to help us with email MX validation for our online checkout app Better Cart (

Small apps and endpoints like this are absolutely perfect on We love knowing that this high demand endpoint is not only going to auto scale when needed, but also scale where it is needed, as this endpoint is being used by our client side apps so scaling near the customers is a huge win.

Let me know if you have any questions, happy to chat!


This is :100: awesome!


This is pretty :fire:.

I’d been experimenting with the Mailgun email validation API but it would be nice to use our own stuff.


We took a look around the web and couldn’t find anything with reasonable usage plans, nor did we even want to pay for something as simple as a MX lookup haha :slight_smile:

We now use this inside our <Formik> forms as a custom validator paired with Yup as well, super clean and simple to implement.

export const validate = email => {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await fetch('FLY_MX_VALIDATE_ENDPOINT', {
        method: 'POST',
        mode: 'cors',
        headers: {
          'Content-Type': 'application/json',
        body: JSON.stringify({
      const data = await response.json()
    } catch (error) {

const CheckoutSchema = Yup.object().shape({
    email: Yup.string()
      .email('Email not valid')
      .required('Email is required')
      .test('email-mx', 'Invalid email domain', async value => {
        const response = await validate(value)
        return response.valid

return (
        email: || '',