Skip to content

dhesend-org/dhesend-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dhesend Node.js SDK

A Node.js library for interacting with the Dhesend API, designed to make email sending simple and efficient. For full documentation, visit the official website.

Installation

Install the SDK using your preferred package manager:

npm install dhesend
# or
yarn add dhesend

Examples

Discover example integrations with various frameworks:

Setup

  1. Obtain an API Key:
    Get your API key from the Dhesend Dashboard.

  2. Initialize the SDK:
    Use your API key to create an instance of the Dhesend client.

import Dhesend from 'dhesend';

const dhesend = new Dhesend('your_api_key_here'); // Replace with your actual API key

Usage

Sending Your First Email

const { data, error } = await dhesend.emails.send({
  from: "example@yourdomain.com",
  to: ['recipient@example.com'],
  subject: 'Welcome to Dhesend',
  textBody: 'Have a nice day!',
});

Sending Emails with Custom HTML

const { data, error } = await dhesend.emails.send({
  from: "example@yourdomain.com",
  to: ['recipient@example.com'],
  subject: 'Welcome to Dhesend',
  htmlBody: '<strong>Have a nice day!</strong>',
});

Advanced Usage

Sending Emails Using React Templates

Step 1: Create a React Component for Your Email Template

import React from 'react';

export default function EmailTemplate({ firstName }) {
  return (
    <div>
      <h1>Welcome, {firstName}!</h1>
      <p>Thanks for signing up with Dhesend.</p>
    </div>
  );
}

Step 2: Convert the Component to HTML and Send the Email

import ReactDOMServer from 'react-dom/server';
import EmailTemplate from '../components/EmailTemplate';

const { data, error } = await dhesend.emails.send({
  from: "Dhesend <example@domain.com>",
  to: ['recipient@example.com'],
  subject: 'Welcome to Dhesend',
  htmlBody: ReactDOMServer.renderToStaticMarkup(<EmailTemplate firstName="Ali" />),
});

License

MIT License.

About

Dhesend Official Node JS SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published