Skip to content

Deno: Send email using Zoho

In this post, you will learn to send emails from your Deno application using Zoho SMTP Servers.

Create a file called SendEmailWithZoho.ts with the below code and don’t forget to update the token (see the steps below to generate), to address from address and bounce_address.

import { SendMailClient } from "https://deno.land/x/deno_zeptomail/mod.ts";

const url = "api.zeptomail.com/";
const token = "<Send mail token>";

let client = new SendMailClient({url, token});

client.sendMail({
  "bounce_address": "[email protected]",
  "from": {
    "address": "[email protected]",
    "name": "noreply",
  },
  "to": [
    {
      "email_address": {
        "address": "[email protected]",
        "name": "Arjun",
      },
    },
  ],
  "subject": "Test Email",
  "htmlbody": "<div><b> Test email sent successfully.</b></div>",
}).then(() => console.log("success")).catch((error) =>
  console.log("error", error)
);

Now run your script and If everything goes well you should get an email in your inbox.

deno run --allow-net .\SendEmailWithZoho.ts

Steps to generate Send mail token:

  1. Navigate to the Mail Agents tab on the left panel of your ZeptoMail account and select a Mail Agent that you want to connect to your application.
  2. On the top right section, click on Setup Info (gear icon). This will open the Setup Details page.
  3. From here you can copy your Mail Agent-specific send mail token under the API tab.
  4. You can use the default Send Mail Token or generate a new one.
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments