【问题标题】:sending mail from R (mailR)从 R (mailR) 发送邮件
【发布时间】:2015-04-04 19:14:46
【问题描述】:

我正在尝试在 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) 中的错误: 无效的“环境”参数

之后我尝试设置一个 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)

我仍然遇到同样的错误。任何帮助将不胜感激。谢谢vm

【问题讨论】:

  • 尝试使用enabling SMTP 访问您的 Google 帐户。

标签: r sendmailr


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    smtp = list(host.name = "smtp.gmail.com", port = 465,
                            ssl=TRUE, user.name = "mymailid@gmail.com",
                            passwd = "my password)
    

    【讨论】:

      【解决方案3】:
      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
      

      【讨论】:

      【解决方案4】:

      你可以试试下面的例子:

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

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

      好运!

      【讨论】:

        【解决方案5】:

        你是用空字符串做body的吗?

        我尝试使用我的公司电子邮件和 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
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-11-10
          • 1970-01-01
          • 2014-05-23
          • 1970-01-01
          • 2019-04-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多