Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/47ng/fastify-ohmysmtp
Fastify plugin for OhMySMTP/MailPace
https://github.com/47ng/fastify-ohmysmtp
fastify-plugin mailer mailpace ohmysmtp
Last synced: about 2 months ago
JSON representation
Fastify plugin for OhMySMTP/MailPace
- Host: GitHub
- URL: https://github.com/47ng/fastify-ohmysmtp
- Owner: 47ng
- License: mit
- Created: 2021-12-23T11:17:39.000Z (about 3 years ago)
- Default Branch: next
- Last Pushed: 2023-03-01T16:58:25.000Z (almost 2 years ago)
- Last Synced: 2024-08-09T07:27:03.597Z (5 months ago)
- Topics: fastify-plugin, mailer, mailpace, ohmysmtp
- Language: TypeScript
- Homepage:
- Size: 402 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
🚧 MIGRATION NOTICE 🚧
[OhMySMTP has rebranded to MailPace](https://blog.mailpace.com/blog/ohmysmtp-is-now-mailpace/). This package will change name soon. If you're considering using it, you might want to wait for v2 to be published under `fastify-mailpace`. This repository will be renamed.
See issue [#7](https://github.com/47ng/fastify-ohmysmtp/issues/7) for progress.
---
fastify-ohmysmtp
[![NPM](https://img.shields.io/npm/v/fastify-ohmysmtp?color=red)](https://www.npmjs.com/package/fastify-ohmysmtp)
[![MIT License](https://img.shields.io/github/license/47ng/fastify-ohmysmtp.svg?color=blue)](https://github.com/47ng/fastify-ohmysmtp/blob/main/LICENSE)
[![Continuous Integration](https://github.com/47ng/fastify-ohmysmtp/workflows/Continuous%20Integration/badge.svg?branch=next)](https://github.com/47ng/fastify-ohmysmtp/actions)
[![Coverage Status](https://coveralls.io/repos/github/47ng/fastify-ohmysmtp/badge.svg?branch=next)](https://coveralls.io/github/47ng/fastify-ohmysmtp?branch=next)## Features
- Send emails
- Webhooks
- Inbound emails _(coming soon)_## Installation
```shell
$ yarn add fastify-ohmysmtp
# or
$ npm i fastify-ohmysmtp
```## Usage
Minimal example:
```ts
import Fastify from 'fastify'
import fastifyOhMySMTP from 'fastify-ohmysmtp'const server = Fastify()
server.register(fastifyOhMySMTP, {
apiToken: 'my-api-token'
})server.ohmysmtp.sendEmail({
from: '[email protected]',
to: '[email protected]',
subject: 'test',
htmlbody: 'HTML Email
'
})
```## Environment Variables
You can provide the API token via the configuration or via the `OHMYSMTP_API_TOKEN` environment variable.
## Webhooks
You can enable reception of webhook events in the configuration object:
```ts
server.register(fastifyOhMySMTP, {
apiToken: 'my-api-token',
webhooks: {
// Where to attach the webhook endpoint (POST)
path: '/webhook',/*
* An object map of handlers, where keys are the event types, listed here:
* https://docs.ohmysmtp.com/guide/webhooks#email-events
*
* Values are async handlers that take as argument:
* - The payload object of the webhook event
* - The request object from Fastify
* - The Fastify instance
*/
handlers: {
'email.spam': async (event, req, fastify) => {
req.log.info(event, 'Spam detected')
await fastify.ohmysmtp.sendEmail({
from: '[email protected]',
to: '[email protected]',
subject: 'Spam detected',
textbody: `Check event ${event.id} on OhMySMTP`
})
}
},// You can pass additional Fastify route props here:
routeConfig: {
logLevel: 'warn'
}
}
})
```## License
[MIT](https://github.com/47ng/fastify-ohmysmtp/blob/main/LICENSE) - Made with ❤️ by [François Best](https://francoisbest.com)
Using this package at work ? [Sponsor me](https://github.com/sponsors/franky47) to help with support and maintenance.