> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gork.email/llms.txt
> Use this file to discover all available pages before exploring further.

# Auth emails with better-auth

> Send verification, OTP, and password-reset mail through Gork REST.

better-auth sends auth mail through callbacks you provide — point them at `POST /v1/messages/send` so verification codes, magic links, and password resets go out through your Gork inbox.

<Note>
  Auth mail is single-recipient by nature, so it fits comfortably on the free sandbox — no custom domain required to start.
</Note>

## Pattern

Wire Gork into better-auth's email callbacks (`sendVerificationEmail`, and `sendVerificationOTP` when using the `emailOTP` plugin). Each callback receives the recipient and content, then POSTs one message:

<CodeGroup>
  ```typescript better-auth + fetch theme={null}
  import { betterAuth } from "better-auth";

  const GORK_API_KEY = process.env.GORK_API_KEY!;
  const GORK_INBOX_ID = process.env.GORK_INBOX_ID!; // inb_...

  async function sendViaGork(to: string, subject: string, text: string) {
    const res = await fetch("https://api.gork.email/v1/messages/send", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${GORK_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ inboxId: GORK_INBOX_ID, to: [to], subject, text }),
    });
    if (!res.ok) throw new Error(`Gork send failed: ${await res.text()}`);
  }

  export const auth = betterAuth({
    emailVerification: {
      sendVerificationEmail: async ({ user, url }) => {
        await sendViaGork(
          user.email,
          "Verify your email",
          `Click to verify your account: ${url}`
        );
      },
    },
  });
  ```

  ```typescript emailOTP theme={null}
  import { betterAuth } from "better-auth";
  import { emailOTP } from "better-auth/plugins";

  export const auth = betterAuth({
    plugins: [
      emailOTP({
        async sendVerificationOTP({ email, otp, type }) {
          const subject =
            type === "sign-in" ? "Your sign-in code"
            : type === "email-verification" ? "Verify your email"
            : "Reset your password";
          await sendViaGork(email, subject, `Your code is: ${otp}`);
        },
      }),
    ],
  });
  ```
</CodeGroup>

## Tips

* Use a dedicated inbox (e.g. `auth` / `no-reply`) so auth mail is isolated from agent outreach.
* Sends are idempotent-safe: pass an `Idempotency-Key` header keyed on `(email, otp)` so retries never double-deliver codes.
* For production volumes on your own domain, verify the domain first (see the [Node.js SDK](/sdk/nodejs) domains section).
