Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

refire-client

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refire-client

Refire Email API Client

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
36
decreased by-80.65%
Maintainers
0
Weekly downloads
 
Created
Source

Refire Email Client

A lightweight TypeScript client for sending transactional emails through the Refire Email API.

Getting Your API Key

Before using the client, you'll need an API key:

  1. Create a company account in the Refire dashboard
  2. Navigate to your company view page
  3. Find your API key in a secure, masked input field
  4. Click the field to copy your API key to clipboard

Keep your API key secure and never share it publicly or commit it to version control.

Installation

npm install refire-client

Usage

Initialize the Client

import { Refire } from "refire-client";

const refire = new Refire({
  apiKey: "your-api-key",
});

You can optionally specify a custom API URL during initialization:

const refire = new Refire({
  apiKey: "your-api-key",
  apiUrl: "https://api.refire.email/v1",
});

Sending Basic Emails

To send a basic email without a template:

refire.sendEmail({
  to: "recipient@example.com",
  subject: "Hello",
  name: "John Doe",
  message: "Your email content here",
});

Sending Template-Based Emails

To send an email using a pre-defined template:

refire.sendEmailFromTemplate({
  to: "recipient@example.com",
  templateId: "<your_template_id>",
});

Method Chaining

You can also use method chaining if preferred:

Sending a basic email:

new Refire("<your_api_key>").sendEmail({
  to: "recipient@example.com",
  subject: "Hello",
  name: "John Doe",
  message: "Your email content here",
});

Sending a template-based email:

new Refire("<your_api_key>").sendEmailFromTemplate({
  to: "recipient@example.com",
  templateId: "<your_template_id>",
});

API Reference

SendEmailParams

Parameters for sending a basic email:

  • to (string): Recipient email address
  • subject (string): Email subject line
  • name (string): Recipient name
  • message (string): Email content

SendEmailFromTemplateParams

Parameters for sending a template-based email:

  • to (string): Recipient email address
  • templateId (string): ID of the template to use

Error Handling

The client includes built-in error handling. Both sendEmail and sendEmailFromTemplate methods will throw an error if the API request fails:

try {
  await refire.sendEmail({
    to: "recipient@example.com",
    subject: "Hello",
    name: "John Doe",
    message: "Your email content here",
  });
} catch (error) {
  console.error("Failed to send email:", error);
}

License

MIT

Author

Refire

For more information and detailed documentation, visit refire.email.

Keywords

FAQs

Package last updated on 12 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc