Skip to main content

Mail Configurations

As mentioned in the previous section, the mailer we use in warlock is nodemailer so you can use any transport supported by nodemailer.

Setup

Navigate to src/config/mail.ts file, and add the following:

src/config/mail.ts
import { env } from "@mongez/dotenv";
import { MailConfigurations } from "@warlock.js/core";

const mailConfigurations: MailConfigurations = {
host: env("MAIL_HOST"),
username: env("MAIL_USERNAME"),
password: env("MAIL_PASSWORD"),
port: env("MAIL_PORT"),
secure: env("MAIL_SECURE"),
from: {
name: env("MAIL_FROM_NAME"),
address: env("MAIL_FROM_ADDRESS"),
},
};

export default mailConfigurations;

Configurations

Now let's see what are the available configurations:

  • host: The mail server host, for example, smtp.gmail.com.
  • username: The mail server username.
  • password: The mail server password.
  • port: The mail server port, for example, 587.
  • secure: Whether to use TLS or not, for example, true.
  • from: The default sender information, it has two properties:
    • name: The sender name.
    • address: The sender email address.

And any other options supported by nodemailer.