Netpress Laravel-inspired backend framework for Node.js
Frameworkv0.1.14 Starterv0.1.12 Docsv1.0.3
Overview Installation Architecture CLI
Features

Mail

Mail rendering is always enabled in the starter and uses either React or Vue. The mail transport and engine are registered during app boot, and mail content can be sent through Mail.send(...) or BaseMail subclasses.

Quick Example

// app/Mail/WelcomeMail.js
import { BaseMail } from "@admicaa/netpress";
import WelcomeMailView from "../../resources/mails/WelcomeMail.jsx";

export default class WelcomeMail extends BaseMail {
  constructor(user) {
    super();
    this.user = user;
  }

  subject() {
    return `Welcome to Netpress, ${this.user.name}!`;
  }

  component() {
    return WelcomeMailView;
  }

  props() {
    return { user: this.user };
  }
}

Config

export default {
  engine: "react",
  driver: process.env.MAIL_DRIVER || "smtp",
  from: {
    address: process.env.MAIL_FROM || "no-reply@netpress.io",
    name: process.env.APP_NAME || "Netpress",
  },
  // smtp, mailgun, or ses config...
};

Valid mail engines:

  • "react"
  • "vue"

Unlike config/view.js, mail does not support null.

Mail.send(...)

Use the helper when you want to send a component directly:

import { Mail } from "@admicaa/netpress";
import WelcomeMailView from "../../resources/mails/WelcomeMail.jsx";

await Mail.send(
  WelcomeMailView,
  { user },
  { to: user.email, subject: `Welcome, ${user.name}` },
);

Mail.send(...) requires a to address from either options.to or props.to. It renders both:

  • HTML
  • plain text

BaseMail

BaseMail gives you a mailable-style class surface:

  • subject()
  • component()
  • props()
  • engine()
  • build()
  • send(to)
  • queue(to)

Override build() directly when you want raw HTML instead of a rendered component.

Queued Mail

BaseMail.queue(to) uses BullMQ. It expects:

  • queue.connection in the container
  • queue.mail optionally in the container, otherwise it defaults to "emails"

The queued job name convention is "SendMail", which the app worker handles.

Template Layout

  • resources/mails/WelcomeMail.jsx or .vue
  • resources/mails/layouts/MailLayout.jsx or .vue

make:mail follows the configured mail engine and writes the correct template extension automatically.