无法使用mailR包通过Outlook.com发送电子邮件 [英] Fail to send email via Outlook.com using mailR package

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

问题描述

我想使用{mailR}软件包发送带有身份验证的电子邮件通知.此软件包由{rJava}支持,并使用Java工具.

I want to use {mailR} package to send email notifications with authentication. This package is backended by {rJava} and uses Java facilities.

我注册了一个Outlook.com帐户.

I registered an Outlook.com account.

代码如下:

library(mailR)
email <- send.mail(
  from="(account-name)@outlook.com",
  to="(my-account)@outlook.com",
  subject="Test message from server",
  body="Hello, this is a test message.",
  smtp=list(host.name="smtp-mail.outlook.com",port=25,
    user.name="(account-name)@outlook.com",passwd="(account-password)", 
    ssl = TRUE),
  authenticate=TRUE,
  send=TRUE
)

我阅读了 http://windows.microsoft. com/zh-CN/windows/outlook/send-receive-from-app ,并尝试了所有可能的主机名(smtp.live.com,smtp.outlook.com,smtp-mail.outlook.com)和端口(25,587),但这都会导致以下错误:

I read http://windows.microsoft.com/en-us/windows/outlook/send-receive-from-app and tried all possible host names (smtp.live.com, smtp.outlook.com, smtp-mail.outlook.com) and ports (25, 587), but it all results in the following error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp-mail.outlook.com:465

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp-mail.outlook.com:465

出什么问题了?是否有可行的解决方案来在R中发送带有身份验证的电子邮件?

What is the problem? Is there a working solution to send email with authentication in R?

推荐答案

尝试下面的代码(经过其他Outlook用户的测试):

Try the code below (been tested by other Outlook users):

send.mail(from = from,
          to = to,
          subject = subject,
          body = msg, 
          authenticate = TRUE,
          smtp = list(host.name = "smtp.office365.com", port = 587,
                      user.name = "xxx@domain.com", passwd = "xxx", tls = TRUE))

这篇关于无法使用mailR包通过Outlook.com发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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