Package 'sendgridr'

Title: Mail Sender Using 'Sendgrid' Service
Description: Send email using 'Sendgrid' <https://sendgrid.com/en-us> mail API(v3) <https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authentication>.
Authors: Chanyub Park [aut, cre]
Maintainer: Chanyub Park <[email protected]>
License: MIT + file LICENSE
Version: 0.6.2
Built: 2024-08-12 02:33:36 UTC
Source: https://github.com/mrchypark/sendgridr

Help Index


set address to sg_mail class

Description

to(), cc(), bcc() is for set email address to sg_mail class

Usage

to(sg_mail, email, name = "")

cc(sg_mail, email, name = "")

bcc(sg_mail, email, name = "")

Arguments

sg_mail

(required)mail object from package

email

(required)email address

name

(optional)name for email address.

Value

sg_mail class with mail address.

Examples

mail() %>%
  to("[email protected]")

mail() %>%
  cc("[email protected]")

mail() %>%
  bcc("[email protected]")

attachments

Description

attachments

Usage

attachments(sg_mail, path, name, content_id)

Arguments

sg_mail

(required)mail object from package

path

(required)file path to attach

name

file name. default is path's file name

content_id

content id. default is Null.

Value

sg_mail class with attachments.

Examples

path <- system.file("extdata", "test.Rmd", package = "sendgridr")
mail() %>%
  attachments(path)

Check API key for auth.

Description

Check API key for auth.

Usage

auth_check()

Value

TRUE/FALSE check work fine return TRUE.


Set API key for auth.

Description

Set API key for auth.

Usage

auth_set(apikey)

Arguments

apikey

sendgrid api key. If key has value, just use as api key. If without param, function call interactive prompt input.

Value

None


body

Description

body

Usage

body(sg_mail, body, type = "text/html")

Arguments

sg_mail

(required)mail object from package

body

(required)mail content html support.

type

content type. text/html is default.

Value

sg_mail class with body content.

Examples

mail() %>%
  body("[email protected]")

Add dynamic template

Description

Create dynamic templates at https://mc.sendgrid.com/dynamic-templates.

Usage

dynamic_template(sg_mail, template_id, template_data, force = FALSE)

Arguments

sg_mail

(required) mail object from package

template_id

(required) template_id start "d-" and 32-length only digit and lower case alphabet like "d-4ad23ad40a0e47d0a0232b85f24ca5c2"

template_data

A key-value list for template data. (See https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates)

force

pass template_id validation. default is FALSE.

Value

sg_mail class with dynamic template

Examples

mail() %>%
  dynamic_template("d-4ad23ad40a0e47d0a0232b85f24ca5c2", list(first_name = "Amanda", link = "foo"))

mail() %>%
  dynamic_template(template_id = "foo",
    template_data = list(first_name = "Amanda", link = "foo"),
    force = TRUE)

Add dynamic template data

Description

template_id must be included for this data to be applied.

Usage

dynamic_template_data(sg_mail, data)

Arguments

sg_mail

(required) mail object from package

data

A key-value list for template data. (See https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates)

Value

sg_mail class with template data for dynamic transactional templates

Examples

data_lst <-
  list(
    first_name = "Amanda",
    link = "foo"
  )

mail() %>%
  template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2")%>%
  dynamic_template_data(data_lst)

Embeding Rmd on body with images.

Description

Embeding Rmd on body with images.

Usage

embed_rmd(sg_mail, input, ...)

Arguments

sg_mail

(required) mail object from package

input

(required) input file path to render for email.

...

extra params pass to emayili::render() function.

Examples

path <- system.file("extdata", "test.Rmd", package = "sendgridr")
mail() %>%
 embed_rmd(path)

from

Description

from

Usage

from(sg_mail, email, name = "")

Arguments

sg_mail

(required)mail object from package

email

(required)email address

name

name for email address

Value

sg_mail class with from mail address.

Examples

mail() %>%
  from("[email protected]")

Set mail class for Sendgrid

Description

New mail class for sendgrid.

Usage

mail()

Value

sg_mail class.

Examples

mail()

Print for sg_mail class

Description

Print for sg_mail class

Usage

## S3 method for class 'sg_mail'
print(x, ...)

Arguments

x

sg_mail class object

...

pass for default print. But not use in sg_mail class.


send mail

Description

Send mail with mail content.

Usage

send(mail)

Arguments

mail

mail object

Value

list if success, success message. and error, please check https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authentication.

Examples

## Not run: 

data_lst <-
  list(
    total = "$239.85",
    name = "Sample Name"
  )

mail() %>%
  from("[email protected]", "example name for display") %>%
  to("[email protected]", "example name for display 2") %>%
  dynamic_template_data(data_lst) %>%
  template_id(template_id) %>%
  subject("test mail title") %>%
  body("hello world!") %>%
  ## attachments is optional
  attachments("report.html") %>%
  send()

## End(Not run)

subject

Description

subject

Usage

subject(sg_mail, subject)

Arguments

sg_mail

(required)mail object from package

subject

(required)mail subject

Value

sg_mail class with subject.

Examples

mail() %>%
  subject("[email protected]")

template id

Description

Create dynamic templates at https://mc.sendgrid.com/dynamic-templates

Usage

template_id(sg_mail, template_id, force = FALSE)

Arguments

sg_mail

(required) mail object from package

template_id

(required) template_id start "d-" and 32-length only digit and lower case alphabet like "d-4ad23ad40a0e47d0a0232b85f24ca5c2"

force

pass template_id validation. default is FALSE.

Value

sg_mail class with template id.

Examples

mail()%>%
  template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2")

mail() %>%
  template_id("foo", force = TRUE)