我正在尝试添加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
答案 0 :(得分:0)
如果turned on access for less secure apps代表您发送的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)
如果你没有打开它,那么你将获得
无效'envir'参数