Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you send email from R

Tags:

r

I want to send emails from R. This is what I have so far:

library(sendmailR)   from <- "[email protected]" to <- "[email protected]" subject <- "Performance Result" body <- "This is the result of the test:"                      mailControl=list(smtpServer="snmpt server address")  sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl) 

When I execute this script, my R session hangs. Any ideas what might be happening?

like image 868
user1471980 Avatar asked May 01 '14 16:05

user1471980


People also ask

Does mailR need Java?

It's a wrapper around Apache Commons Email, an email library built on top of the Java Mail API. Due to this, mailR has a dependency on the rJava package, a low-level interface to Java VM. This requires Java Runtime Environment to be installed.

What does via mean in email?

You'll see "via" and a website name next to the sender's name if: The domain it was sent from doesn't match the domain in the "From:" address. For example, you got an email from [email protected], but it could've been sent through a social networking site and not Gmail.


1 Answers

If you need to be able to use an smtp server with authentication you can use the mailR package.

For example using gmail's smtp server:

library(mailR) sender <- "[email protected]" recipients <- c("[email protected]") send.mail(from = sender,           to = recipients,           subject = "Subject of the email",           body = "Body of the email",           smtp = list(host.name = "smtp.gmail.com", port = 465,                        user.name = "[email protected]",                                   passwd = "YOURPASSWORD", ssl = TRUE),           authenticate = TRUE,           send = TRUE) 
like image 123
alko989 Avatar answered Sep 28 '22 09:09

alko989