Files
myeasycms-v2/packages/mailers
giancarlo d275d993bd Add 'vercel-email' package and update Cloudflare mailer implementation
The 'vercel-email' package was added as a dependency to facilitate sending emails using Cloudflare workers. The CloudflareMailer class has been updated to leverage 'vercel-email' for sending emails. Instructions for setting up the 'vercel-email' package with the Cloudflare provider were added to the README.md file. The
2024-04-09 17:39:54 +08:00
..
2024-03-24 02:23:22 +08:00

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

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!'
  });
}

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