Skip to contents

Methods for creating and sending MIME messages.

Usage

sg_mime()

sg_from(x, email)

sg_to(x, ...)

sg_cc(x, ...)

sg_bcc(x, ...)

sg_subject(x, subject)

sg_body(x, body, type = "text/html")

sg_attachments(x, ...)

sg_send(x, api_key = Sys.getenv("SENDGRID_API_KEY"))

Arguments

x

A MIME object.

email

The sender's email address.

...

One or more email addresses.

subject

The email subject.

body

The body content of the email.

type

The content type (e.g., "text/plain")

api_key

SendGrid API key. Defaults to the environment variable SENDGRID_API_KEY if not provided.

Value

A MIME object.

Examples

if (FALSE) { # \dontrun{
  sg_mime() |>
    sg_from("sender@example.com") |>
    sg_to("recipient1@example.com", "recipient2@example.com") |>
    sg_cc("cc1@example.com", "cc2@example.com") |>
    sg_bcc("bcc1@example.com", "bcc2@example.com") |>
    sg_subject("This is the subject") |>
    sg_body("Hello from sg!") |>
    sg_attachments("path/to/file1.csv", "path/to/file2.pdf") |>
    sg_send()
} # }