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

@techie04/xpresser-mailer

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@techie04/xpresser-mailer

Mailer Plugin for xpresser

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
2
Weekly downloads
 
Created
Source

XpresserJs Mailer Plugin

Build Status License npm version

A library to help you send mails.

This plugin makes use of nodemailer and aws-sdk ses.

MENU

Installation

npm i @techie04/xpresser-mailer

# OR
yarn add @techie04/xpresser-mailer

Add to plugins.json

{
  "npm://@techie04/xpresser-mailer": true
}

Add to your project config.

({
    // SMTP CONFIG
    "mailer": {
        provider: "SMTP", // SMTP
        configs: {
            smtp: {
                host: "", // SMTP Server Host
                port: "", // SMTP Server Port
                username: "", // SMTP Server Username
                password: "", // SMTP Server Password
                fromEmail: "no-reply@example.com" // From email
            },
            
            aws: {
                region: "", // AWS Server Region
                fromEmail: "no-reply@example.com", // From email
                // AWS credentials
                AWS_ACCESS_KEY_ID: "",
                AWS_SECRET_ACCESS_KEY: ""
            },
            
            postmark: {
                apiToken: ""
            }
        }
    },

})

Usage

In your controller or anywhere in your project.

Javascript
const { sendMail } = require("@techie04/xpresser-mailer");

await sendMail(message);
Typescript
import { sendMail } from "@techie04/xpresser-mailer";

await sendMail<Message, MessageResponse>(message);
  • Message: Type of message content (depending on provider)
  • MessageResponse: Type of response returned to the sendMail function (depending on provider)

Creating a custom provider

Create a file, maybe providers/CustomProvider.ts

import { MailProvider } from "@techie04/xpresser-mailer/MailProvider";

// The name should be the same with the config key.
const CustomProvider = new MailProvider("customProvider", {
    /**
     * Initialize your provider.
     * @param config - The config for your provider. i.e mailer.configs.customProvider
     * @param $ - xpresser instance
     */
    initialize(config, $) {
        // Validate config here
        // return client.
    },

    /**
     * Send mail function.
     * @param mail - the mail object or data
     * @param config - The config for your provider. i.e mailer.configs.customProvider
     * @param client - The client returned from the initialize function above.
     * @param $
     */
    sendMail({ mail, config, client }, $) {
        // Send mail here.
    }
});

export default CustomProvider;
Add to config
const config = {
    "mailer": {
        // ... other configs
        customProviders: {
            // key is providers name
            // value is path to provider file without .js or .ts
            customProvider: "providers/CustomProvider"
        }
    }
}

Keywords

FAQs

Package last updated on 10 Nov 2021

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