New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@upyo/smtp

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@upyo/smtp

SMTP transport for Upyo email library

Source
npmnpm
Version
0.4.0-dev.77
Version published
Maintainers
1
Created
Source

@upyo/smtp

JSR npm

SMTP transport implementation for the Upyo email library.

Features

  • Full SMTP protocol implementation
  • TLS/SSL support
  • Connection pooling
  • Multiple authentication methods
  • HTML and plain text email support
  • File attachments (regular and inline)
  • Multiple recipients (To, CC, BCC)
  • Custom headers
  • Priority levels
  • Comprehensive testing utilities
  • TypeScript support
  • Cross-runtime compatibility (Node.js, Bun, Deno)
  • STARTTLS support for secure connection upgrade
  • DKIM signing support (RSA-SHA256 and Ed25519-SHA256)

Installation

npm  add       @upyo/core @upyo/smtp
pnpm add       @upyo/core @upyo/smtp
yarn add       @upyo/core @upyo/smtp
deno add --jsr @upyo/core @upyo/smtp
bun  add       @upyo/core @upyo/smtp

Usage

Basic Email Sending

import { createMessage } from "@upyo/core";
import { SmtpTransport } from "@upyo/smtp";

const transport = new SmtpTransport({
  host: "smtp.example.com",
  port: 587,
  secure: false,
  auth: {
    user: "username",
    pass: "password",
  },
});

const message = createMessage({
  from: "sender@example.com",
  to: "recipient@example.net",
  subject: "Hello from Upyo!",
  content: { text: "This is a test email." },
});

const receipt = await transport.send(message);
if (receipt.successful) {
  console.log("Message sent with ID:", receipt.messageId);
} else {
  console.error("Send failed:", receipt.errorMessages.join(", "));
}

Sending Multiple Emails

const messages = [message1, message2, message3];

for await (const receipt of transport.sendMany(messages)) {
  if (receipt.successful) {
    console.log(`Email sent with ID: ${receipt.messageId}`);
  } else {
    console.error(`Email failed: ${receipt.errorMessages.join(", ")}`);
  }
}

Configuration options

SmtpConfig

OptionTypeDefaultDescription
hoststringSMTP server hostname
portnumber587SMTP server port
securebooleantrueUse TLS/SSL connection
authSmtpAuthAuthentication configuration
tlsSmtpTlsOptionsTLS configuration
connectionTimeoutnumber60000Connection timeout (ms)
socketTimeoutnumber60000Socket timeout (ms)
localNamestring"localhost"Local hostname for HELO/EHLO
poolbooleantrueEnable connection pooling
poolSizenumber5Maximum pool connections
dkimDkimConfigDKIM signing configuration

SmtpAuth

OptionTypeDefaultDescription
userstringUsername
passstringPassword
method"plain" | "login" | "cram-md5""plain"Auth method

DKIM signing

DKIM (DomainKeys Identified Mail) signing is supported for improved email deliverability and authentication:

import { createMessage } from "@upyo/core";
import { SmtpTransport } from "@upyo/smtp";
import { readFileSync } from "node:fs";

const transport = new SmtpTransport({
  host: "smtp.example.com",
  port: 587,
  secure: false,
  auth: { user: "user@example.com", pass: "password" },
  dkim: {
    signatures: [{
      signingDomain: "example.com",
      selector: "mail",
      privateKey: readFileSync("./dkim-private.pem", "utf8"),
    }],
  },
});

DkimConfig

OptionTypeDefaultDescription
signaturesDkimSignature[]Array of DKIM signature configs
onSigningFailure"throw" | "send-unsigned""throw"Action when signing fails

DkimSignature

OptionTypeDefaultDescription
signingDomainstringDomain for DKIM key (d= tag)
selectorstringDKIM selector (s= tag)
privateKeystring | CryptoKeyPrivate key (PEM string or CryptoKey)
algorithm"rsa-sha256" | "ed25519-sha256""rsa-sha256"Signing algorithm
canonicalizationstring"relaxed/relaxed"Header/body canonicalization
headerFieldsstring[]From, To, ...Headers to sign

Testing

Mock SMTP Server

For unit testing, use the included mock SMTP server:

import { MockSmtpServer, SmtpTransport } from "@upyo/smtp";

const server = new MockSmtpServer();
const port = await server.start();

const transport = new SmtpTransport({
  host: "localhost",
  port,
  secure: false,
  auth: { user: "test", pass: "test" },
});

// Send test email
await transport.send(message);

// Check received messages
const received = server.getReceivedMessages();
console.log(received[0].data); // Raw email content

await server.stop();

Keywords

email

FAQs

Package last updated on 24 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts