Skip to content

nutrivetpet/postmarkr

Repository files navigation

postmarkr

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. R-CMD-check Codecov test coverage

The goal of postmarkr is to interact with the Postmark API, from R.

It is an independent, community-developed R package for the Postmark email service (not created by or affiliated with Postmark).

Installation

You can install the development version of postmarkr like so:

pak::pak("nutrivetpet/postmarkr")

Usage Patterns

postmarkr provides a clean, object-oriented API for sending emails through Postmark. The package supports two message types (email and template) and two delivery modes (individual and batch):

email() template()
Individual One email with HTML/text body One email using template ID
Batch Multiple custom emails (500+) Multiple template emails (500+)

Individual Email (Custom Content)

Send a single email with custom HTML or text content:

library(postmarkr)

# Create client
client <- client(
  token = Sys.getenv("POSTMARK_SERVER_TOKEN"),
  message_stream = "outbound"
)

# Create and send email
email <- email(
  from = "[email protected]",
  to = "[email protected]",
  subject = "Welcome to postmarkr",
  html_body = "<h1>Hello!</h1><p>Welcome to our service.</p>",
  track_opens = TRUE
)

result <- send(client, email)

Individual Template Email

Send a single email using a predefined Postmark template:

template <- template(
  from = "[email protected]",
  to = "[email protected]",
  id = 36620093L,
  template_model = list(
    user_name = "Alice",
    company_name = "ACME Corp"
  ),
  track_opens = TRUE
)

result <- send(client, template)

Batch Emails

Send multiple custom emails efficiently (automatically chunks into groups of 500):

# Create multiple personalized emails
emails <- lapply(recipients, function(recipient) {
  email(
    from = "[email protected]",
    to = recipient,
    html_body = "<p>Hi %s, welcome aboard!</p>"
  )
})

# Wrap in batch and send
batch <- batch(messages = emails)
result <- send(client, batch)

Batch Templates

Send multiple template emails (e.g., newsletters, notifications):

# Create template emails for each recipient
templates <- lapply(recipients, function(recipient) {
  template(
    from = "[email protected]",
    to = recipient,
    id = 36620093L,
    template_model = list(
      user_name = "Alice",
      company_name = "ACME Corp"
    )
  )
})

# Wrap in batch and send
batch <- batch(messages = templates)
result <- send(client, batch)

Features

  • Custom Emails: Compose emails with HTML or text using email()
  • Template Emails: Use Postmark templates with variable substitution via template()
  • Batch Sending: Efficiently send 500+ emails with batch() (automatic chunking)
  • Tracking: Built-in support for open and click tracking

Note: Postmark API coverage is limited. See the documentation for all available features.

About

Email Delivery Made Simple: Unofficial Postmark API Integration for R

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages