Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

836 B
Raw Blame
import { pretty, render } from "@react-email/render";
import nodemailer from "nodemailer";
import { CreateEmailOptions } from "resend";

// Send email using NodeMailer (Recommended for local development)
export const sendViaNodeMailer = async ({
  to,
  subject,
  text,
  react,
}: Pick<CreateEmailOptions, "subject" | "text" | "react"> & {
  to: string;
}) => {
  const transporter = nodemailer.createTransport({
    // @ts-ignore (Fix this)
    host: process.env.SMTP_HOST,
    port: process.env.SMTP_PORT,
    auth: {
      user: process.env.SMTP_USER,
      pass: process.env.SMTP_PASSWORD,
    },
    secure: false,
    tls: {
      rejectUnauthorized: false,
    },
  });

  return await transporter.sendMail({
    from: "[email protected]",
    to,
    subject,
    text,
    html: await pretty(await render(react)),
  });
};