R/send_email.R

Defines functions send_email

Documented in send_email

#' Send a postfix email
#' @param to email address of the recipient
#' @param subject subject of email
#' @param body body of the email
#' @importFrom secretary typewrite
#' @importFrom crayon italic
#' @export

send_email <-
    function(to,
            subject,
             body) {

        command <- paste0("echo '", body, "' | mail -s", " '", subject, "' ", to)
        return_msg <- system(command, intern = TRUE)
        if (length(return_msg) > 0) {
            print(return_msg)
        } else {
            secretary::typewrite("\tEmail", crayon::italic(subject), "in queue to", crayon::italic(to), ".\n")
        }
    }
meerapatelmd/postfixR documentation built on Jan. 1, 2021, 9:28 a.m.