我正试图在Windows 7(家用)机器上从R发送邮件。我尝试了以下代码
send.mail(from = "mymailid@gmail.com",
to = c("mymailid@gmail.com"),
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "myuserid", passwd = "my password", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
我收到以下错误: ls中的错误(envir = envir,all.names = private): 无效' envir'参数
之后我尝试设置一个hmail服务器(使用本地域名和用户帐户,smtp设置为smtp.gmail.com:25)
send.mail(from = "localuser@localdomain.local",
to = c("mymailid@gmail.com"),
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "mail.hmailserver.com", port = 25),
authenticate = FALSE,
send = TRUE)
我仍然得到同样的错误。任何帮助将不胜感激。谢谢vm
答案 0 :(得分:4)
如果您使用的是gmail帐户,则可能需要使用此链接https://www.google.com/settings/security/lesssecureapps
允许您使用安全性较低的帐户访问您的帐户如果你还有2步验证,你还需要停用它。
答案 1 :(得分:2)
如果您的Gmail帐户设置正确(正如mOhawk建议的那样),则此表单应适用于smtp
列表:
smtp = list(host.name = "smtp.gmail.com", port = 465,
ssl=TRUE, user.name = "mymailid@gmail.com",
passwd = "my password)
答案 2 :(得分:1)
i am trying to send email using RDCOMClient and here is the code
library(RDCOMClient)
emails <- paste("emailid")
## init com api
OutApp <- COMCreate("Outlook.Application")
## create an email
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = emails
outMail[["Cc"]] = "emailid"
outMail[["subject"]] = "Monthly Report for Compliance"
outMail[["body"]] = paste(" Please find the monthly report completed for ",Sys.Date(),
".\n\n instrument file is saved at:\n G:\\Data Science\\Monthly Check - Westlake\\Instruments and Issuers Compliance List
"
)
outMail[["attachments"]]$Add("G:\\Data Science\\Monthly Check - Westlake\\Instruments and Issuers Compliance List\\Instruments_tracked-.02202018.csv")
outMail$Send()
I get the below error
<checkErrorInfo> 80020009
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352567
答案 3 :(得分:0)
您可以尝试以下示例:
library(mail)
to <- "albert.physik@gmail.com"
subject <- "mail of R"
msg <- paste("Testing!")
sendmail(to, subject , msg)
但只允许您每天发送20封电子邮件 我希望你觉得它很有用。
运气!
答案 4 :(得分:0)
你是否使用空字符串作为正文?
我尝试使用公司电子邮件和Gmail。当我把
body = "", # quotation marks with nothing in between
它产生
ls中的错误(envir = envir,all.names = private):无效'envir' 参数
虽然这有效:
body = " ", # adding a space there
根本不知道为什么......如果你碰巧有空字符串,这可能会有所帮助。
主题为空字符串不会导致问题:
subject = "", # quotation marks with nothing in between