Skip to content

Postmark Email Provider

To use Resend as your email provider, you need to create an account and obtain your API Key.

Then copy your API key and add it to the .env file

POSTMARK_API_KEY='your-postmark-api-key'

The code for Postmark is found in server/_/mail/poviders/postmark.ts

ts
import postmark from 'postmark'
import type {
  SendEmailHandler,
  SendEmailParams,
  SendEmailWithHtml,
  SendEmailWithText,
} from '~/server/_/mail/types'

const config = useRuntimeConfig()
const client = new postmark.ServerClient(config.postmarkApiKey)

export const send: SendEmailHandler = async (params: SendEmailParams) => {
  const { subject, recipient: to } = params

  // Type assertion to safely access html and text properties
  const html = (params as SendEmailWithHtml).html
  const text = (params as SendEmailWithText).text

  await client.sendEmail({
    From: config.emailSenderAddress,
    To: to,
    Subject: subject,
    HtmlBody: html,
    TextBody: text,
  })
}

For more information, pleasw refer to the Postmark docs