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 |
to(), cc(), bcc() is for set email address to sg_mail class
to(sg_mail, email, name = "") cc(sg_mail, email, name = "") bcc(sg_mail, email, name = "")
to(sg_mail, email, name = "") cc(sg_mail, email, name = "") bcc(sg_mail, email, name = "")
sg_mail |
(required)mail object from package |
email |
(required)email address |
name |
(optional)name for email address. |
sg_mail class with mail address.
mail() %>% to("[email protected]") mail() %>% cc("[email protected]") mail() %>% bcc("[email protected]")
mail() %>% to("[email protected]") mail() %>% cc("[email protected]") mail() %>% bcc("[email protected]")
attachments
attachments(sg_mail, path, name, content_id)
attachments(sg_mail, path, name, content_id)
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. |
sg_mail class with attachments.
path <- system.file("extdata", "test.Rmd", package = "sendgridr") mail() %>% attachments(path)
path <- system.file("extdata", "test.Rmd", package = "sendgridr") mail() %>% attachments(path)
Check API key for auth.
auth_check()
auth_check()
TRUE/FALSE check work fine return TRUE.
Set API key for auth.
auth_set(apikey)
auth_set(apikey)
apikey |
sendgrid api key. If key has value, just use as api key. If without param, function call interactive prompt input. |
None
body
body(sg_mail, body, type = "text/html")
body(sg_mail, body, type = "text/html")
sg_mail |
(required)mail object from package |
body |
(required)mail content html support. |
type |
content type. text/html is default. |
sg_mail class with body content.
mail() %>% body("[email protected]")
mail() %>% body("[email protected]")
Create dynamic templates at https://mc.sendgrid.com/dynamic-templates.
dynamic_template(sg_mail, template_id, template_data, force = FALSE)
dynamic_template(sg_mail, template_id, template_data, force = FALSE)
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. |
sg_mail class with dynamic template
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)
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)
template_id
must be included for this data to be applied.
dynamic_template_data(sg_mail, data)
dynamic_template_data(sg_mail, data)
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) |
sg_mail class with template data for dynamic transactional templates
data_lst <- list( first_name = "Amanda", link = "foo" ) mail() %>% template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2")%>% dynamic_template_data(data_lst)
data_lst <- list( first_name = "Amanda", link = "foo" ) mail() %>% template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2")%>% dynamic_template_data(data_lst)
Embeding Rmd on body with images.
embed_rmd(sg_mail, input, ...)
embed_rmd(sg_mail, input, ...)
sg_mail |
(required) mail object from package |
input |
(required) input file path to render for email. |
... |
extra params pass to emayili::render() function. |
path <- system.file("extdata", "test.Rmd", package = "sendgridr") mail() %>% embed_rmd(path)
path <- system.file("extdata", "test.Rmd", package = "sendgridr") mail() %>% embed_rmd(path)
from
from(sg_mail, email, name = "")
from(sg_mail, email, name = "")
sg_mail |
(required)mail object from package |
email |
(required)email address |
name |
name for email address |
sg_mail class with from mail address.
mail() %>% from("[email protected]")
mail() %>% from("[email protected]")
New mail class for sendgrid.
mail()
mail()
sg_mail class.
mail()
mail()
Print for sg_mail class
## S3 method for class 'sg_mail' print(x, ...)
## S3 method for class 'sg_mail' print(x, ...)
x |
sg_mail class object |
... |
pass for default print. But not use in sg_mail class. |
Send mail with mail content.
send(mail)
send(mail)
mail |
mail object |
list if success, success message. and error, please check https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authentication.
## 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)
## 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
subject(sg_mail, subject)
subject(sg_mail, subject)
sg_mail |
(required)mail object from package |
subject |
(required)mail subject |
sg_mail class with subject.
mail() %>% subject("[email protected]")
mail() %>% subject("[email protected]")
Create dynamic templates at https://mc.sendgrid.com/dynamic-templates
template_id(sg_mail, template_id, force = FALSE)
template_id(sg_mail, template_id, force = FALSE)
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. |
sg_mail class with template id.
mail()%>% template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2") mail() %>% template_id("foo", force = TRUE)
mail()%>% template_id("d-4ad23ad40a0e47d0a0232b85f24ca5c2") mail() %>% template_id("foo", force = TRUE)