【问题标题】:Send authenticated mails via Outlook through R using mailR package使用 mailR 包通过 R 通过 Outlook 发送经过身份验证的邮件
【发布时间】:2019-04-04 02:11:44
【问题描述】:

如何通过 Outlook 从 R 发送邮件?

有人告诉我使用sendmailR 包,但我不知道如何指定certain control settings(例如端口、用户名和密码)。我也被重定向到this post,但没有帮助。

我切换到mailR 包。我可以从其他服务器发送邮件,例如smtp.gmail.com,但我不知道 Outlook 服务器的详细信息。使用mailR 通过 Outlook 发送邮件所需的协议、服务器和端口详细信息是什么?

【问题讨论】:

    标签: r outlook smtp


    【解决方案1】:

    我花了一段时间才弄清楚。试试这个:

    send.mail(from = "username@custom.org",
              to = c("recipient1@custom.org", "recipient2@custom.org"),
              subject = "Title",
              body = "Hello from R.",
              authenticate = TRUE,
              smtp = list(host.name = "smtp.office365.com",
                      port = 587,
                      user.name = "username@custom.org",
                      passwd = "Pa55w0rd",
                      tls = TRUE))
    

    端口是25或447是一个常见的误解。我相信25端口只能在authenticate = FALSE时使用。

    许多消息来源声称正确的服务器是smtp-mail.outlook.com。如果代码不起作用,也许你可以试试这个。此外,请勿使用ssl = TRUE。必须是tls = TRUE

    感谢 Rahul Premraj 对this archived 2014 question 的回答。

    【讨论】:

      【解决方案2】:

      或者你可以使用DescTools::SendOutlookMail()

      library(DescTools)
      SendOutlookMail(to = c("me@microsoft.com", "you@rstudio.com"), 
                      subject = "Some Info", 
                      body = "Hi all\r Find the files attached\r Regards, Dude", 
                      attachment = c("C:/temp/fileA.txt", 
                                     "C:/temp/fileB.txt"))
      

      【讨论】:

      • 我试过这个,但我得到以下错误: 80020009 不支持 InterfaceSupportsErrorInfo checkErrorInfo -2147352567 错误:发生异常。另外:警告消息:在 RDCOMClient::getCOMInstance(app) 中:创建 Outlook.Application 的新实例而不是连接到现有实例。
      • 您是否检查过所有附件是否存在?尝试使用有效的电子邮件地址、主题和正文并报告。
      猜你喜欢
      • 2011-05-03
      • 2017-09-26
      • 2014-07-03
      • 2014-05-23
      • 2016-11-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      • 2013-06-23
      相关资源
      最近更新 更多