1.1.0 • Published 5 years ago

@dupkey/mail v1.1.0

Weekly downloads
4
License
MIT
Repository
gitlab
Last release
5 years ago

@dupkey/mail

Email messages and mailer. Provides response and transport interfaces so new transport agents can be added.

Currently only supports Mailgun transactional email templates.

Install

npm install @dupkey/mail

Example

import { Mailer, MailgunTransport, MessageSettings, Email } from '@dupkey/mail';
import * as Mailgun from 'mailgun-js';

const transport = new MailgunTransport(new Mailgun({
  apiKey: process.env.MAILGUN_KEY,
  domain: process.env.MAILGUN_DOMAIN
}));

export const mailer = new Mailer(
  transport,
  new Email('support'.concat('@', process.env.SENDMAIL_HOST), process.env.CLIENT_NAME),
  { client: process.env.CLIENT_NAME, uri: process.env.CLIENT_URI },
  (process.env.SENDMAIL === 'true')
);

const message = new Message(
  new Email('you@test.com', 'You'),
  'template',
  'subject',
  { data: 'foo' },
);

const response = async () => await mailer.send(message);

You will probably want to wire up your transport and mailer dependencies and then re-use throughout your app.

Build the TypeScript and JavaScript versions

npm run build

Run the tests

npm test

VS Code Debugging

Create a launch.json file in your .vscode folder with the following:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Mocha Tests",
      "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
      "args": [
        "--require", "ts-node/register",
        "-u", "tdd",
        "--timeout", "999999",
        "--colors", "--recursive",
        "${workspaceFolder}/test/**/*.ts"
      ],
      "internalConsoleOptions": "openOnSessionStart"
    }
  ]
}

In the debug tab (Ctrl+Shift+D) select "Mocha Tests" from the dropdown and then click "Start Debugging". Results will display in the console on the bottom of the VS Code.

1.1.0

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago