0.3.1 • Published 5 months ago

@xeuxdev/easymailer v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

EasyMailer

This package is a zero-config helper function to help you send emails in your nodejs apps using nodemailer 🚀🚀

this package provides support for the following transports

  • Gmail
  • SMTP

What you need to use this package

Intall this package into your project using any package manager

  • npm
    npm i @xeuxdev/easymailer
  • pnpm
  pnpm i @xeuxdev/easymailer

Set up your environment variables

  • using gmail

    • you need the following environment variables
MAILER_GOOGLE_USER_EMAIL = "example@gmail.com"
MAILER_GOOGLE_USER_PASSWORD = "password"

To get the password env, create an app password in your google account

  • using smtp

    • you need the following environment variables
MAILER_SMTP_USERNAME = "your smtp username"
MAILER_SMTP_PASSWORD = "your smtp password"
MAILER_SMTP_HOST = "your smtp host"
MAILER_SMTP_PORT = "smtp host"

you can get all the above env from your hosting account

How to work with the package

  • import the package into your server code
import { sendMail } from "@xeuxdev/easymailer"
or
const { sendMail } = require("@xeuxdev/easymailer")
  • call the function with the params
const response = await sendMail({
  message: {},
  transport: {},
})

props

message

  • from - required - the name of the sender
  • subject - required - The subject of the email
  • html - required - The HTML version of the message
  • plainText - required - The plaintext version of the message
  • attachments - required - An array of attachment objects
  • to - optional - Comma separated list or an array of recipients email addresses that will appear on the To: field
  • cc - optional - Comma separated list or an array of recipients email addresses that will appear on the Cc: field
  • bcc - optional - Comma separated list or an array of recipients email addresses that will appear on the Bcc: field

transport

  • service: - required - "gmail" | "smtp"
  • secure?: - optional - boolean - default: true
  • pool?: - optional - boolean - default: true
  • grouped?: - optional - boolean - default: true

Response

  • you get a response object after calling the sendMail() function
{
  message: string
  status: "failed" | "successful"
}

Compatibility

mailer is compatible with all server codes, such as express, Nextjs API routes

Happy Coding

0.3.0

5 months ago

0.3.1

5 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.1.1

7 months ago

0.1.0

7 months ago