npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arikajs/mail

v0.10.7

Published

Email delivery system for the ArikaJS framework.

Downloads

786

Readme

Arika Mail

@arikajs/mail is the email delivery system for the ArikaJS framework.

It provides a driver-based, configurable mailer with support for templated emails, attachments, and queue-ready delivery — with a beautiful, expressive API but built natively for Node.js and TypeScript.

This package allows applications to send emails without coupling to a specific transport.


✨ Features

  • Multiple mailers: Configure different mail transports (SMTP)
  • Driver-based transport system: Pluggable email backends
  • Class-based Mailables: Reusable email classes
  • Templated emails: Using @arikajs/view for rendering
  • Attachments: Via @arikajs/storage integration
  • Multiple Recipients: Full support for to, cc, and bcc
  • Queue-ready: Native async delivery via @arikajs/queue
  • Plain text & HTML emails: Support for both formats
  • TypeScript-first: Full type safety with JavaScript support

📦 Installation

npm install @arikajs/mail
# or
yarn add @arikajs/mail
# or
pnpm add @arikajs/mail

🚀 Quick Start

Sending a Basic Email

import { Mail } from '@arikajs/mail';

await Mail.to('[email protected]')
  .subject('Welcome')
  .text('Welcome to ArikaJS!')
  .send();

📬 Using Email Templates

await Mail.to('[email protected]')
  .subject('Welcome')
  .view('emails.welcome', { user })
  .send();

Templates are rendered using @arikajs/view.


✉️ Mailables (Recommended)

Mailables provide a clean, reusable way to define emails.

import { Mailable } from '@arikajs/mail';

export class WelcomeMail extends Mailable {
  constructor(private user: any) {
    super();
  }

  build() {
    return this
      .subject('Welcome to ArikaJS')
      .view('emails.welcome', { user: this.user });
  }
}

Sending a mailable:

await Mail.to(user.email).send(new WelcomeMail(user));

Queuing a mailable:

await Mail.to(user.email).queue(new WelcomeMail(user));

Attachments

Attach files using Arika Storage:

await Mail.to('[email protected]')
  .subject('Invoice')
  .attach('invoices/2024.pdf')
  .send();

From raw data (Buffer):

const buffer = await generatePdf(data);

await Mail.to('[email protected]')
  .attachData(buffer, 'invoice.pdf')
  .send();

From streams:

const stream = getDynamicReportStream();

await Mail.to('[email protected]')
  .attachStream(stream, 'report.csv')
  .send();

Multiple Recipients

await Mail.to('[email protected]')
  .cc(['[email protected]', '[email protected]'])
  .bcc('[email protected]')
  .subject('Notification')
  .send();

Queued Delivery

Arika Mail integrates with @arikajs/queue for background processing.

import { Queue } from '@arikajs/queue';

// Configure queue on the mail system
Mail.setQueue(queueManager);

// Dispatch to background
await Mail.to('[email protected]').queue(new WelcomeMail(user));

⚙️ Configuration

Mail configuration is defined via the application config:

export default {
  default: process.env.MAIL_MAILER || 'log',

  mailers: {
    smtp: {
      transport: 'smtp',
      host: process.env.MAIL_HOST || 'smtp.mailtrap.io',
      port: Number(process.env.MAIL_PORT || 587),
      username: process.env.MAIL_USERNAME,
      password: process.env.MAIL_PASSWORD,
      encryption: process.env.MAIL_ENCRYPTION || 'tls',
    },

    log: {
      transport: 'log',
    },

    array: {
      transport: 'array',
    },
  },

  from: {
    address: process.env.MAIL_FROM_ADDRESS || '[email protected]',
    name: process.env.MAIL_FROM_NAME || 'Example',
  },
};

🚚 Supported Transports (v1)

| Transport | Status | Description | | :--- | :--- | :--- | | SMTP | ✅ Supported | Standard SMTP delivery | | Log | ✅ Supported | Logs emails to console (for local dev) | | Array | ✅ Supported | Stores emails in memory (for testing) | | SES | ✅ Supported | Amazon SES driver | | Mailgun | ✅ Supported | Mailgun API driver | | SendGrid | ✅ Supported | SendGrid API driver |


📚 API Reference

Mail.to(address)

Set the recipient email address.

Mail.to('[email protected]')

replyTo(address)

Set the Reply-To address.

.replyTo('[email protected]')

subject(text)

Set the email subject.

.subject('Welcome')

text(content)

Set plain text email content.

.text('Plain text email')

view(name, data)

Render an email template.

.view('emails.reset', { token })

attach(path)

Attach a file from storage.

.attach('reports/file.pdf')

send(mailable?)

Send the email.

await Mail.to('[email protected]').send();

or with a Mailable:

await Mail.to(user.email).send(new WelcomeMail(user));

🏗 Architecture

mail/
├── src/
│   ├── Contracts
│   │   └── Transport.ts
│   ├── Jobs
│   │   └── SendQueuedMailable.ts
│   ├── Transport
│   │   ├── ArrayTransport.ts
│   │   ├── LogTransport.ts
│   │   ├── MailgunTransport.ts
│   │   ├── SendGridTransport.ts
│   │   ├── SesTransport.ts
│   │   └── SmtpTransport.ts
│   ├── index.ts
│   ├── Mailable.ts
│   ├── Mailer.ts
│   ├── MailManager.ts
│   └── Message.ts
├── tests/
├── package.json
├── tsconfig.json
└── README.md

🔌 Extending Mail (Custom Transports)

Create a custom transport:

import { Transport } from '@arikajs/mail';

class CustomTransport implements Transport {
  async send(message: any): Promise<void> {
    // Implementation
  }
}

Register it with MailManager.


🔗 Integration with ArikaJS

@arikajs/mail integrates with:

  • @arikajs/view → Email templates
  • @arikajs/storage → Attachments
  • @arikajs/queue → Async email delivery
  • @arikajs/config → Mailer configuration

🧪 Testing

Mailables and transports can be mocked for testing. A log or array transport will be added for test environments.


🛣 Roadmap

  • [ ] Queue-based sending
  • [ ] Markdown email support
  • [ ] Multiple recipients (CC/BCC)
  • [ ] Mail previews
  • [ ] Retry & failure handling

📄 License

@arikajs/mail is open-source software licensed under the MIT License.


🧭 Philosophy

"Send emails, not headaches."