Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending mail from R (mailR)

Tags:

r

sendmailr

I am trying to send mail from R on a windows 7 (home) machine. I tried the following code

send.mail(from = "[email protected]",
          to = c("[email protected]"),
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "myuserid", passwd = "my password", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)

I get the following error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument

after that I tried set up an hmail server (with a local domain name and user account, and smtp set up for smtp.gmail.com:25)

send.mail(from = "[email protected]",
          to = c("[email protected]"),
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "mail.hmailserver.com", port = 25),
          authenticate = FALSE,
          send = TRUE)

I still get the same error. Any help will be greatly appreciated. Thanks vm

like image 346
Prodipta Ghosh Avatar asked Feb 11 '23 12:02

Prodipta Ghosh


1 Answers

If you're using gmail account, you might need to allow acess to your account from less secure aplications, using this link https://www.google.com/settings/security/lesssecureapps

If you have as well a 2 step verification, you also need to deactivate that.

like image 161
user3116408 Avatar answered Feb 13 '23 02:02

user3116408