how do you send email from R

后端 未结 8 879
情书的邮戳
情书的邮戳 2020-11-29 18:11

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

library(sendmailR)


from <- \"eamil@example.com\"
to <- \"email2@example.com\"
subject <-         


        
相关标签:
8条回答
  • 2020-11-29 18:51

    I found the simplest way in Ubuntu is to run the one liner Terminal command in R. No need for password.

    try(system("mutt -s 'Run is complete.' youremail@anymail.com < /dev/null", intern = TRUE))

    You will need to install mutt in terminal before this.

    0 讨论(0)
  • 2020-11-29 18:52

    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 <- "SENDER@gmail.com"
    recipients <- c("RECIPIENT@gmail.com")
    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 = "YOURUSERNAME@gmail.com",            
                          passwd = "YOURPASSWORD", ssl = TRUE),
              authenticate = TRUE,
              send = TRUE)
    
    0 讨论(0)
提交回复
热议问题