I am trying to add an HTML mail body. 'path_to_html' is clearly visible but I am not able to mail.
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)
I get the following error :
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
If you turned on access for less secure apps for the Gmail account, over which you are sending ( foo@gmail.com
in the example below), then this works like a charm:
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)
If you haven't turned it on, then you'll get
invalid 'envir' argument
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.