Reindex
TeamBlogDocs

Sending emails

A very common task in many applications is sending emails. Sending emails is surprisingly hard and thus many people embrace service providers that allow sending emails. This guide illustrates using Reindex hooks to send emails with Mailgun.

We will use Zapier, an app that connects different APIs together. This way you could later use any other integrations that Zapier provides. You can also use a custom backend or any other API integrator instead.

First go to Zapier and register. We will connect Zapier WebHook app and Mailgun. Choose ‘Catch hook’ action in WebHook app and ‘Send email’ action in Mailgun. You will get a hook url, save it somewhere. Zapier will ask you to connect the Mailgun account and after that you are ready to go.

Let’s send email every time a new Todo is created. First we need to get an id of the Todo ReindexType.

{
  reindexTypeByName(name: "Todo") {
    id,
  }
}

Now we can create our hook

mutation createhook {
  createReindexHook(input: {
    type: "YOUR-TODO-REINDEXTYPE-ID",
    trigger: afterCreate,
    url: "https://zapier.com/hooks/catch/YOUR-ZAPIER-HOOK/",
    fragment: "{ changedTodo { text, user { email } } }"
  }) {
    id
  }
}

After you create a Todo, Zapier will analyze the structure of your hook and you should be able to select appropriate fields for Recipient and a template to format an email. You can also add a Zapier filter that will check that user’s email is present.

Topics:

Sending emails

A very common task in many applications is sending emails. Sending emails is surprisingly hard and thus many people embrace service providers that allow sending emails. This guide illustrates using Reindex hooks to send emails with Mailgun.

We will use Zapier, an app that connects different APIs together. This way you could later use any other integrations that Zapier provides. You can also use a custom backend or any other API integrator instead.

First go to Zapier and register. We will connect Zapier WebHook app and Mailgun. Choose ‘Catch hook’ action in WebHook app and ‘Send email’ action in Mailgun. You will get a hook url, save it somewhere. Zapier will ask you to connect the Mailgun account and after that you are ready to go.

Let’s send email every time a new Todo is created. First we need to get an id of the Todo ReindexType.

{
  reindexTypeByName(name: "Todo") {
    id,
  }
}

Now we can create our hook

mutation createhook {
  createReindexHook(input: {
    type: "YOUR-TODO-REINDEXTYPE-ID",
    trigger: afterCreate,
    url: "https://zapier.com/hooks/catch/YOUR-ZAPIER-HOOK/",
    fragment: "{ changedTodo { text, user { email } } }"
  }) {
    id
  }
}

After you create a Todo, Zapier will analyze the structure of your hook and you should be able to select appropriate fields for Recipient and a template to format an email. You can also add a Zapier filter that will check that user’s email is present.