Skip to contents

Sends an email using a predefined template.

Usage

template_send_email(
  from,
  to,
  id,
  template_model,
  msg_stream,
  tag = NULL,
  track_opens = FALSE,
  token = NULL
)

Arguments

from

Character scalar. Email address of the sender.

to

Character vector. Email addresses of recipients (max 50).

id

A single integer. The template ID in Postmark.

template_model

A named list. Variables to be populated in the template.

msg_stream

Character scalar. Either "outbound" or "broadcast".

tag

A single character string. Optional tag for categorizing the email. Maximum 1000 characters. Default is NULL.

track_opens

A logical value. Whether to track when recipients open the email. Default is FALSE.

token

Character string. Your Postmark API token. If NULL (default), the function will attempt to retrieve the token using get_token() POSTMARK_SERVER_TOKEN as an environment variable. Check the Postmark's API documentation on how to get a server token.

Value

A data frame containing the JSON response from the Postmark API, invisibly.

Examples

if (FALSE) { # \dontrun{
template_send_email(
  from = "sender@example.com",
  to = c("recipient1@example.com", "recipient2@example.com"),
  id = 12345,
  template_model = list(
    name = "John",
    message = "Hello from Postmark!"
  ),
  msg_stream = "outbound",
  tag = "welcome-email",
  track_opens = TRUE
)
} # }