0

我正在尝试添加 HTML 邮件正文。'path_to_html' 清晰可见,但我无法邮寄。

 library(mailR)
 library(R2HTML)
   heading <- c(
"<html>
<head>
<body>
<p> A new program </p></br>


</br>



</body>
</html>")

path_to_html <- "e:/mailer.html"

HTML(heading, file = path_to_html, append = TRUE)
  send.mail(from = "abc@xyz.com",to = mail_list,                                                           
        subject =  "Hi",
        body = path_to_html,
        html = TRUE,
        inline = TRUE,
        smtp = list(host.name = "smtp.gmail.com", port = 465, user.name ="abc@xyz.com" , 
                    passwd = "XXXXXX", ssl = TRUE),
        authenticate = TRUE,
        attach.files = path_attach_pdf,
        send = TRUE)

我收到以下错误:

  Error in ls(envir = envir, all.names = private) : 
  invalid 'envir' argument
4

1 回答 1

0

如果您为您发送邮件的 Gmail 帐户打开了对不太安全的应用程序foo@gmail.com的访问(在下面的示例中),那么这就像一个魅力:

writeLines(text="<html><body><p>test</p></body></html>", tf <- tempfile(fileext = ".html"))
library(mailR)
send.mail(from = "<foo@gmail.com>",
          to = "<bar@gmail.com>",
          subject = "test",
          body = tf,
          html = TRUE,
          smtp = list(host.name = "smtp.gmail.com", 
                      port = 465, 
                      user.name = "foo", 
                      passwd = "password", 
                      ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)

如果你还没有打开它,那么你会得到

无效的“环境”参数

于 2015-11-04T14:49:24.810 回答