how do you send email from R

后端 未结 8 929
情书的邮戳
情书的邮戳 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:49

    There is a new package called emayili with two very interesting promises:

    • works on all manner of SMTP servers
    • has minimal dependencies (or dependencies which are easily satisfied)

    It seems early stages but promising nonetheless. Sending email is as simple as:

    devtools::install_github("datawookie/emayili")
    library(emayili)
    library(dplyr)
    
    email <- envelope() %>%
      from("alice@yahoo.com") %>%
      to("bob@google.com") %>%
      subject("This is a plain text message!") %>%
      body("Hello!")
    
    smtp <- server(host = "smtp.gmail.com",
                   port = 465,
                   username = "bob@gmail.com",
                   password = "bd40ef6d4a9413de9c1318a65cbae5d7")
    
    smtp(email, verbose = TRUE)
    

提交回复
热议问题