Send Email from R

In R, there is a package named mailR that allows you to send emails from R.

R Code : Send Email from R
library(mailR)
send.mail(from="sandy.david@gmail.com",
to="deepanshu.bhalla@outlook.com",
subject="Test Email",
body="PFA the desired document",
html=T,
smtp=list(host.name = "smtp.gmail.com",
port = 465,
user.name = "sandy.david@gmail.com",
passwd = "xxxxxxxxx",
ssl = T),
authenticate=T,
attach.files="C:\\Users\\Deepanshu\\Downloads\\Nature of Expenses.xls")
You can add multiple recipients including the following code.
to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
cc = c("CC Recipient <cc.recipient@gmail.com>"),
bcc = c("BCC Recipient <bcc.recipient@gmail.com>")

R Tutorials : 75 Free R Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like banking, Telecom, HR and Health Insurance.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*
Related Posts:
7 Responses to "Send Email from R"
  1. wow, it is the edge of R ("era eRa" - in Polish) :)

    ReplyDelete
  2. gmail doesnt allow any non gmail app to send email.
    In my case it is not working

    ReplyDelete
  3. Nice article ...one question ,can we attach outlook signature in the email created by the R program?...If yes,the how?

    ReplyDelete
  4. Can we send file data as table and text message both in mail using R. The body part either sends message or table.

    ReplyDelete
  5. Incase you get any error:
    1. Enable access to 'less secure apps' here:

    http://www.google.com/settings/security/lesssecureapps

    2. Disable two step authentication

    ReplyDelete

Next → ← Prev