send_gmailr <- function(from, to, subject, body) {
# Send email with 'gmailr' package wrapped in a single function
#
# Arguments:
# from {char} -- from email address
# to {char} -- to email address
# subject {char} -- email subject
# body {char} -- email body
#
# Returns:
# nothing
#
# Parameter examples:
# to = "aksooklaris@ucdavis.edu"
# from = "Andoni Sooklaris <andoni.sooklaris@gmail.com>"
# body = "This is a test email sent with gmailr"
# subject = "Send Email with Gmailr!"
library(gmailr)
library(purrr)
stopifnot(is.character(from))
stopifnot(is.character(to))
stopifnot(is.character(body))
stopifnot(is.character(subject))
# Create MIME message object
message = gmailr::mime() %>%
gmailr::from(from) %>%
gmailr::to(to) %>%
gmailr::text_body(body) %>%
gmailr::subject(subject)
# Send message
gmailr::send_message(mail = message)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.