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

1.0.4 • Public • Published

Postal Server SDK for TypeScript

license

Welcome to Postal Server SDK for TypeScript! 🎉

This is a friendly and easy-to-use library for interfacing with the open source mail delivery platform, Postal. It's written in TypeScript, to provide type safety and autocompletion for a better developer experience. Our aim is to make sending emails as enjoyable and as painless as possible!

Installation

You can easily install this SDK with npm:

npm install postal-ts

Or with yarn:

yarn add postal-ts

Usage

Here's a simple example of how to send an email ✉️ with this SDK:

import { Postal } from "postal-ts";

const postal = new Postal("postal.your-domain.com", "your-server-key");

postal.send({
    from: "contact@your-domain.com",
    to: "someone@their-domain.com",
    subject: "Hello, Postal!",
    body: "This is a simple test email.",
  });

You can also use an html body just with the isHtml label:

postal.send({
    ...
    body: "<h1>This is an awesome title</h1><p>Followed by a paragraph</p>",
    isHtml: true,
  })

Do you have multiple recipients? Just use an array:

postal.send({
    to: ["someone1@their-domain.com", "someone2@their-domain.com"],
    ...
  })

You can also add cc, bcc, sender and replyTo fields:

postal.send({
    cc: "cc@their-domain.com",
    bcc: "bcc@their-domain.com",
    sender: "i-am-the-sender@your-domain.com",
    replyTo: "reply-me@your-domain.com",
    ...
  })

You can also pass an array for cc and bcc fields:

postal.send({
    cc: ["cc1@their-domain.com", "cc2@their-domain.com"],
    bcc: ["bcc1@their-domain.com", "bcc2@their-domain.com"],
    ...
  })

The send method returns sent messages with their ids:

const { id, messages } = await postal.send(...);

Acknowledgements

Huge thanks to the creators of Postal, the open source mail delivery platform that inspired this project. We are standing on the shoulders of giants! 🙏 Check out their official documentation to learn more about what you can do with Postal and this SDK.

Contributing

As an open source project, we welcome contributions of all sorts! Whether it's filing an issue, fixing a bug, improving documentation, or adding a new feature, your contributions are greatly appreciated. Please take a look at our Contributing Guidelines for more information on how you can contribute.

License

This project is licensed under the MIT License.

Questions? Need Help?

Please don't hesitate to open an issue if you have any questions or need any help. We're here to help you out! You can also reach us at hello@widenex.com.

Happy emailing! 💌


Made with 🖤 by Widenex

Package Sidebar

Install

npm i postal-ts

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

19.9 kB

Total Files

34

Last publish

Collaborators

  • widenex