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

cloudflare-smtp

v0.1.2

Published

Tiny SMTP client for Cloudflare Workers with TLS and STARTTLS support.

Readme

cloudflare-smtp

Tiny SMTP client for Cloudflare Workers. It uses Cloudflare's cloudflare:sockets API and supports plain SMTP, implicit TLS, and STARTTLS.

Install

bun add cloudflare-smtp
npm install cloudflare-smtp

You can also install directly from GitHub:

npm install github:Bruol/cloudflare-smtp

Quick Start

import { sendMail } from 'cloudflare-smtp';

export default {
	async fetch() {
		await sendMail(
			{
				host: 'smtp.example.com',
				port: 465,
				username: 'smtp-user',
				password: 'smtp-password',
				from: 'Website <[email protected]>',
				to: '[email protected]'
			},
			{
				subject: 'Hello from a Worker',
				text: 'This email was sent through SMTP from Cloudflare Workers.'
			}
		);

		return new Response('sent');
	}
};

Transport Modes

By default, cloudflare-smtp chooses the transport from the port:

  • Port 465: implicit TLS
  • Port 587: STARTTLS
  • Any other port: plain SMTP

You can also set it explicitly:

await sendMail(
	{
		host: 'smtp.example.com',
		port: 587,
		secureTransport: 'starttls',
		username: env.SMTP_USER,
		password: env.SMTP_PASSWORD,
		from: '[email protected]',
		to: ['[email protected]', '[email protected]']
	},
	{
		subject: 'STARTTLS example',
		text: 'STARTTLS was negotiated before authentication.'
	}
);
await sendMail(
	{
		host: 'smtp.example.com',
		port: 465,
		secureTransport: 'tls',
		username: env.SMTP_USER,
		password: env.SMTP_PASSWORD,
		from: '[email protected]',
		to: '[email protected]'
	},
	{
		subject: 'TLS example',
		text: 'The socket connected with TLS from the start.'
	}
);

Available secureTransport values:

  • auto: choose from the port number
  • tls: implicit TLS, usually port 465
  • starttls: connect in STARTTLS mode and upgrade before authentication, usually port 587
  • off: plain SMTP

API

sendMail(config, message)

Sends one plain-text email.

config:

  • host: SMTP hostname
  • port: SMTP port, defaults to 465 for tls and 587 otherwise
  • username: SMTP username
  • password: SMTP password
  • from: sender address
  • to: one recipient or an array of recipients
  • secureTransport: optional transport mode
  • heloName: optional EHLO name, defaults to cloudflare-smtp.local
  • messageIdDomain: optional domain for the generated Message-ID, defaults to host

message:

  • subject: email subject
  • replyTo: optional reply-to address
  • text: plain text body

Notes

This package is built for Cloudflare Workers and requires the cloudflare:sockets runtime module. It is not a Node.js SMTP client.

The current message builder sends plain-text email with UTF-8 headers and body content.

Publishing

This repository publishes to npm from GitHub Actions with npm trusted publishing.

In npm package settings, add this trusted publisher:

  • Publisher: GitHub Actions
  • Organization or user: Bruol
  • Repository: cloudflare-smtp
  • Workflow filename: publish.yml

Then publish a new version by pushing a matching tag:

npm version patch
git push --follow-tags