R/sendEmail.R

Defines functions sendEmail

sendEmail <- function(from, to, plaintext, html, inline, subject, attachment, url, api_key){
  if(!is.na(html)) html <- readChar(html, nchars = file.info(html)$size)
  if(!is.na(inline)) html <- inline
  if(!is.na(attachment)) attachment <- httr::upload_file(attachment)
  the_body <-
    list(
      from=from,
      to=to,
      subject=subject,
      text=plaintext,
      html=html,
      attachment=attachment
    )
  req <- httr::POST(url,
                    httr::authenticate("api", api_key),
                    encode = "multipart",
                    body = the_body[!is.na(the_body)])
  httr::stop_for_status(req)
}

Try the IMmailgun package in your browser

Any scripts or data that you put into this service are public.

IMmailgun documentation built on May 1, 2019, 8:20 p.m.