[R] Sending E-Mail from R

Brahm, David David.Brahm at geodecapital.com
Mon Nov 12 23:01:37 CET 2007


Josh Kalish <joshkalish at gmail.com> wrote:

> Has anyone used R to send out an email via an SMTP server?

If your system is Unix or Linux and you use a system call to "mail",
you might be interested to know that "uuencode" is a good way to include
attachments.  Create a temp file containing your body text, then append
the output of "uuencode" to the end of it.  Here's a piece of code:

temp <- tempfile("Smail.")
cat(text, file=temp, sep="\n")
for (i in seq(along=attach))
  system(paste("uuencode", attach[i], name[i], ">>", temp))
recip <- paste(recip, collapse=" ")
system(paste("mail -s '", subject, "' ", recip, "<", temp, sep=""),
TRUE)
unlink(temp)

-- David Brahm (brahm at alum.mit.edu) 



More information about the R-help mailing list