4

我正在尝试在 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.gmail.com:25 设置了 smtp)

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)

我仍然得到同样的错误。任何帮助将不胜感激。谢谢虚拟机

4

5 回答 5

4

如果您使用的是 gmail 帐户,您可能需要允许从不太安全的应用程序访问您的帐户,使用此链接https://www.google.com/settings/security/lesssecureapps

如果您还有两步验证,则还需要停用它。

于 2015-10-29T14:37:16.487 回答
3

如果您的 gmail 帐户设置正确(如 mOnhawk 建议的那样),那么此表单应该适用于smtp列表:

smtp = list(host.name = "smtp.gmail.com", port = 465,
                        ssl=TRUE, user.name = "mymailid@gmail.com",
                        passwd = "my password)
于 2015-04-05T08:54:27.013 回答
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
于 2018-02-20T21:44:40.123 回答
0

您可以尝试以下示例:

library(mail)

to <-  "albert.physik@gmail.com"
subject <- "mail of R"
msg <- paste("Testing!")
sendmail(to, subject , msg)

但只允许您每天发送 20 封电子邮件,希望您觉得它有用。

运气!

于 2015-10-29T14:44:32.043 回答
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
于 2016-09-22T07:15:36.023 回答