Skip to content

Instantly share code, notes, and snippets.

@sahilseth
Last active April 9, 2016 02:18
Show Gist options
  • Save sahilseth/b37072ff64c29ca5241cfff0578321c5 to your computer and use it in GitHub Desktop.
Save sahilseth/b37072ff64c29ca5241cfff0578321c5 to your computer and use it in GitHub Desktop.
sending mail from R with attachments
library(sendmailR)
send_mail <- function(msg="", subject, tos = c("[email protected]"), attachment}
from <- sprintf("<abc@%s.inst.edu>", Sys.info()[4])
if(missing(subject))
subject <- paste("morning!")
salute <- paste("Hello there\n I just ran the tracker on ")
body <- c(salute, "\n", msg, "\n", mime_part(attachment))
sapply(tos,function(to) sendmail(from, to, subject, body, control=list(smtpServer="mail.institute.org")))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment