DEV Community

Play Button Pause Button

Posted on

Sending emails in Deno using SMTP module

Hey Developers!

I have created a tutorial for sending emails from your deno project using third party module called smtp.


  • You can send email from your deno application.
  • Where we use this thing?
    • Sending verification email to the user after his registration on our project.
    • Sending emails like monthly newsletter, blogs, etc.

Getting Started

import { SmtpClient } from "";
import "";
  • Creating an instance of SmtpClient
const client = new SmtpClient();
  • Accessing environmental variables
const { SEND_EMAIL, PWD, RECV_EMAIL } = Deno.env.toObject();
  • Configuring & Creating the connection
const connectConfig: any = {
  hostname: "",
  port: 465,
  username: SEND_EMAIL,
  password: PWD,
await client.connectTLS(connectConfig);
  • Sending the e-mail to the rec. account
await client.send({
  from: SEND_EMAIL,
  subject: "Welcome!",
  content: "Hi from Vuelancer!",
  • Finally, closing the smtp client connection
await client.close();

Run the app

$ deno run --allow-read --allow-env --allow-net server.ts

Or else clone this repo and sculpt it!

  • you can find the entire code on my github account

    GitHub logo Vuelancer / deno-email-smtp

    Sending emails using smtp module in deno

    Sending Emails using SMTP in Deno


    • Clone the repository.
    • create .env file.
    • Add SEND_EMAIL,PWD,RECV_EMAIL values to it.
    • Visit your if you're using gmail.
    • In Security section, switch on the less secure access

    Run the application using the follg. command

    $ deno run --allow-read --allow-env --allow-net server.js

    • I have uploaded a tutorial for this project in my youtube channel Vuelancer

~ Thank You!

Support Me

Top comments (0)