@embr-dev/mail-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Mail Service

A lightweight server and api to send emails utilizing cloudflare workers.

Prerequisites

  • A cloudflare account with an active domain
  • Nodejs, npm & git installed on your machine
  • A brain (optional)

Deploying the worker

You must log into/be logged into wrangler to deploy the worker. Wrangler docs

Run these commands to deploy the worker:

# Clone the repository
git clone https://github.com/embr-dev/mail-service
cd mail-service

# Install scripts and deploy
npm i -D
npm run worker deploy

Once you have ran the commands above you should get an output containing your api key and the url of your server. You will need these to use the api

Using the api

Installing the package:

npm i @embr-dev/mail-service

An example implementation using the package mimetext.

import { createMimeMessage } from 'mimetext';
import MSClient from 'mail-service';

const recipient = 'recipient@example.com';
const sender = 'email@mydomain.com';

const mailClient = new MSClient('https://your-deployment-url.workers.dev', 'your api key here');
const msg = createMimeMessage();

mailClient.setSender(sender);

// Additional documentation for mimetext can be found here: https://www.npmjs.com/package/mimetext
msg.setSender({ name: 'MSClient', addr: sender });
msg.setRecipient(recipient);
msg.setSubject('Automated Message');
msg.addMessage({
    contentType: 'text/plain',
    data: 'Hello, this is an automated message.'
});

await mailClient.send(recipient, msg.asRaw());

Readme

Keywords

none

Package Sidebar

Install

npm i @embr-dev/mail-service

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.47 kB

Total Files

5

Last publish

Collaborators

  • russsell2259