Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use sendmailR with Windows

Tags:

I'm trying to run sendmailR on Windows with the following code:

## Not run: 
from <- "<[email protected]>" # sprintf("<sendmailR@\\%s>", Sys.info()[4])
to <- "<[email protected]>"
subject <- "Hello from R"
body <- list("It works!", mime_part(iris))
sendmail(from, to, subject, body,
         control=list(smtpServer="ASPMX.L.GOOGLE.COM."))

And get the following error:

Error in socketConnection(host = server, port = port, blocking = TRUE) : 
  cannot open the connection
In addition: Warning message:
In socketConnection(host = server, port = port, blocking = TRUE) :
  smtp.gmail.com [email protected]:statisfun:25 cannot be opened

The answer here give a solution for Linux, and I would be grateful for advice for Windows users.

Thanks.

like image 430
Tal Galili Avatar asked Mar 14 '13 22:03

Tal Galili


1 Answers

You could give the new mailR package a shot: http://cran.r-project.org/web/packages/mailR/index.html

The following call should then work:

send.mail(from = "[email protected]",
          to = "[email protected]",
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "tal.galili", passwd = "PASSWORD", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)
like image 151
Rahul Premraj Avatar answered Sep 23 '22 08:09

Rahul Premraj