[R] Does R have a command for sending emails?
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Tue May 10 14:48:22 CEST 2005
Fernando Saldanha wrote:
> Is there a way to have an R program send an email?
>
> Something like this:
>
> address <- 'abc at d.com'
> text <- 'This is the email body'
> send.email(address, text)
>
> Thanks.
>
> FS
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
Under Linux/Unix you can use code such as the following. This handles
kmail and mail.
if(mailer=='kmail') {
tf <- tempfile()
cat(cmd, file=tf)
to <- paste('"', paste(to, collapse=','), '"', sep='')
if(length(cc)) cc <- paste(' -c "', paste(cc,
collapse=','),'"',sep='')
if(length(bcc)) bcc <- paste(' -b "', paste(bcc,
collapse=','),'"',sep='')
} else {
to <- paste(to, collapse=' ')
if(length(cc)) cc <- paste(paste(' -c', cc), collapse='')
if(length(bcc)) bcc <- paste(paste(' -b', bcc),collapse='')
}
cmd <- if(mailer=='kmail') paste('kmail -s "', title, '"', cc,
bcc, ' --msg ', tf, ' ', to, sep='') else
paste('echo -e "', cmd, '" | mail -s "',
title, ' Reports"', cc, bcc, ' ', to, sep='')
system(cmd)
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list