Deno is a popular alternative runtime for Javascript and has found a great niche in performance and security optimized environments. One common requirement in these settings is for Deno email server setup to enable sending and receiving email using SMTP. Luckily there are some great packages for how to send / receive email using Deno and in this Deno SMTP tutorial we will show you how!

Quick introduction to Deno

Deno is a JavaScript and TypeScript runtime built on V8, the Google engine powering Chrome, and written in Rust. It was created by Ryan Dahl, the original creator of Node.js, as an attempt to address some of Node.js's design limitations. Dahl introduced Deno to incorporate best practices and modern programming standards.

Differences Between Deno and Node.js

Key differences include:

  • Security: Deno is secure by default, requiring explicit permission for file, network, and environment access.
  • Modules: Deno uses ES modules and doesn't need a package manager; imports are done via URLs.
  • TypeScript: Deno supports TypeScript out of the box, without needing transpilation.

Advantages of Using Deno

Deno offers several advantages:

  • Improved security model.
  • Simplified dependency management.
  • Built-in TypeScript support, enhancing developer productivity and code reliability.
  • Quick startup time

These features make Deno a compelling choice for modern web applications and serverless environments. In these environments we commonly need to send and receive email using SMTP, which we can with Deno email integration. Let's get into that!

SMTP and Email Sending in Deno

SMTP (Simple Mail Transfer Protocol) is a protocol for sending email messages between servers. You can use Deno email libraries to send emails using SMTP with third-party modules like denomailer and smtp. Both offer a way to integrate email sending capabilities into Deno projects, with slight differences in their APIs and functionalities. Additionally, SMTP servers enable Deno email relay, allowing you to send emails from your Deno applications. This flexibility can enhance your Deno email development efforts, assisting you in creating tailored email systems suited to each project's needs.

Installing Deno and Initializing a Project

To install Deno, run the installation command specific to your operating system from the Deno official website. To initialize a new project, create a directory, and start adding your or files as needed. Then install Deno like so:

On Mac or Linux

On Windows

Initialize a project

Once Deno is installed, you can initialize a new project by creating a directory and adding your .ts or .js files as needed. This step is crucial for setting up your Deno environment and preparing for Deno SMTP server setup and email functionality integration.


To bootstrap a new Deno project you can run:

This will create the files you need to get started.

How to send mail with Deno

Now that we have Deno installed we have two popular options for sending emails. Let's cover those now.

Sending Emails Using

is a module designed for sending emails in Deno. It simplifies the process with a high-level API. Here's a basic example:

Sending Emails with the Package

The package offers another approach to send emails in Deno. It provides a lower-level API for those who need more control over the email sending process. Example:

Running deno with correct permissions

Deno has a modular permissions model meaning that certain actions like sending email require explicit permission. You can run the above code with the flag to allow network access.

Creating a mailserver

Notice these examples we used an SMTP server for sending. This is because sending mail requires we relay the message through an SMTP server. You need to make sure your mailserver has an exposed port and that the correct access details are used with both Deno libraries.

You can use a service like MailSlurp to create a new SMTP server for free. Then you can connect to it using the or packages. It's easy to get started, and you can use it for testing and development. It supports Deno and other Javascript runtimes like Bun and NodeJS.

Bonus: Deno email best practices

Enhance email deliverability and avoid spam filters when using Deno by implementing authentication protocols like SPF, DKIM, and DMARC. Keep your email list clean by regularly removing inactive or bounced addresses. Provide valuable content to engage recipients and reduce the risk of triggering spam filters. Additionally, ensure the reliability of your email functionality by incorporating Deno email testing into your testing strategies.

Wrapping Up

This article has shown how to use Deno to send emails. Deno is a secure platform for sending and receiving emails in JavaScript and TypeScript applications, ideal for modern web development. With its support for ES modules, TypeScript, and default security settings, Deno simplifies the process of adding email functionality. Its compatibility with different JavaScript runtimes and modular permissions model ensures reliable email delivery. Overall, Deno offers a straightforward solution for developers' email needs.