Files
myeasycms-v2/packages/mailers/README.md
giancarlo f7ded6f789 Add support for Resend mailer
This update expands the mailer support by adding the Resend mailer as an alternative to NodeMailer and Cloudflare Mailer. After setting the environment variable 'MAILER_PROVIDER' to 'resend', users can utilize the Resend HTTP API for mailing. Necessary instructions and variable settings regarding the usage of Resend mailer have also been added to README.md and related modules.
2024-04-17 18:42:00 +08:00

1.3 KiB

Mailers - @kit/mailers

This package is responsible for sending emails using a unified interface across the app.

The default mailer uses the nodemailer package to send emails. You can create custom mailers by extending the Mailer class.

Make sure the app installs the @kit/mailers package before using it.

{
    "name": "my-app",
    "dependencies": {
        "@kit/mailers": "*"
    }
}

Usage

By default, the package uses nodemailer.

To use Cloudflare, please set the environment variable MAILER_PROVIDER to cloudflare.

MAILER_PROVIDER=cloudflare

To use Resend's HTTP API, please set the environment variable MAILER_PROVIDER to resend.

MAILER_PROVIDER=resend

Send an email

import { getMailer } from '@kit/mailers';

async function sendEmail() {
  const mailer = await getMailer();

  return mailer.sendEmail({
    to: '',
    from: '',
    subject: 'Hello',
    text: 'Hello, World!'
  });
}

Cloudflare

If you're using the cloudflare provider, please also read the instructions of the package Vercel Email to setup your Workers.

Resend

If you're using the resend provider, please add the following environment variables:

RESEND_API_KEY=your-api-key