cloudmailin
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published
CloudMailin Logo

CloudMailin Node.js Library

A Node.JS SDK for CloudMailin written in Typescript for receiving incoming email via JSON HTTP POST.

Please see the Documentation for more details and examples.

Usage

You can install the library using NPM.

npm install cloudmailin

Receiving Email

We recommend you take a look at our Documentation for a more detailed example but here's a snippet:

import express from "express";
import bodyParser from "body-parser";
import { IncomingMail } from "cloudmailin";

const app = express();
app.use(bodyParser.json());

app.post("/incoming_mails/", (req, res) => {
  const mail = <IncomingMail>req.body;

  res.status(201).json(mail);
}

Sending Email

import { MessageClient } from "cloudmailin"

const client = new MessageClient({ username: USERNAME, apiKey: API_KEY});
const response = await client.sendMessage({
  to: 'test@example.net',
  from: 'test@example.com',
  plain: 'test message',
  html:  '<h1>Test Message</h1>',
  subject: "hello world"
});

Development

Generating the OpenAPI reference:

npx openapi-typescript ./path_to/api.yaml --output ./src/models/cloudmailin-api.ts

/cloudmailin/

    Package Sidebar

    Install

    npm i cloudmailin

    Weekly Downloads

    561

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    25.8 kB

    Total Files

    24

    Last publish

    Collaborators

    • scsmith