使用 mailR 包通过 R 通过 Outlook 发送经过身份验证的邮件 [英] Send authenticated mails via Outlook through R using mailR package

查看:10
本文介绍了使用 mailR 包通过 R 通过 Outlook 发送经过身份验证的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I send mails from R via Outlook?

有人告诉我使用 sendmailR 包,但我不知道如何指定 某些控制设置(例如端口、用户名和密码).我也被重定向到 这篇文章,但它没有帮助.

I was told to use the sendmailR package, but I could not figure out how to specify certain control settings (such as port, username and password). I was also redirected to this post, but it did not help.

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

I switched to the mailR package. I can send mails from other servers, such as smtp.gmail.com, but I do not know the Outlook server details. What are the protocol, server and port details required to send mails via Outlook using mailR?

推荐答案

我花了一段时间才弄明白.试试这个:

This took me a while to figure out. Try this:

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 时使用.

It is a common misconception that the port is 25 or 447. I believe port 25 can only be used whenauthenticate = FALSE.

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

Many sources claim that the correct server is smtp-mail.outlook.com. Perhaps you could try this in the event that the code does not work. Moreover, do not use ssl = TRUE. It has to be tls = TRUE.

大喊 Rahul Premraj 对 这个归档的 2014 年问题.

Shoutout to Rahul Premraj's answer to this archived 2014 question.

这篇关于使用 mailR 包通过 R 通过 Outlook 发送经过身份验证的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆