3

我正在尝试sendmailR使用以下代码使用包从 R 发送电子邮件,但不幸的是失败了:

## Set mail contents
from <- sprintf('<sendmailR@%s>', Sys.info()[4])
to <- '<slackline@gmail.com>'
subject <- 'Feeding Plots'
body <- list('Latest feeding graph', mime_part(feeding.plot,
                                               name = "feeding"))
## Set control parameters
control <- sendmail_options(verboseShow = TRUE, 
                            smtpServer ="smtp.gmail.com", 
                            smtpPort = 587, 
                            smtpSTARTTLS = '',
                            blocking = FALSE)
sendmail(from,
         to,
         subject,
         msg = body,
         control = control,
         headers)
<< 220 mx.google.com ESMTP xt1sm884721wjb.17 - gsmtp
>> HELO  kimura
<< 250 mx.google.com at your service
>> MAIL FROM:  <sendmailR@kimura>
<< 530 5.7.0 Must issue a STARTTLS command first. xt1sm884721wjb.17 - gsmtp
Error in wait_for(code) : 
  SMTP Error: 5.7.0 Must issue a STARTTLS command first. xt1sm884721wjb.17 - gsmtp

sendmailR 手册没有提到如何配置,尽管STARTTLS它确实表明可以传递其他参数,这就是为什么我根据其他一些线程( hereheresmtpSTARTLS = ''中提到的内容包含了该选项。我尝试过使用 for 的参数并将其设置为但没有乐趣。smtpSTARTTLSTRUE

任何指向文档或解决方案的指针都将受到欢迎。

谢谢

4

2 回答 2

3

据我了解,sendmailR不支持任何类型的 SMTP 服务器登录,因此,gmail 基本上无法使用。如果您在正确的网络中并设置一个只能在我猜的网络内访问的服务器(即不使用身份验证的服务器),您只能使用该软件包。

另一种选择是mail包裹(您不能在其中使用自己的地址)。

sendmailR 文档中的参考资料是:

当前不支持 SMTP AUTH。

于 2014-01-29T11:28:33.260 回答
2

你可以给新的mailR包一个允许SMTP授权的镜头:http ://cran.r-project.org/web/packages/mailR/index.html

然后应该可以使用以下调用:

send.mail(from = "slackline@gmail.com",
          to = "slackline@gmail.com",
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "slackline", passwd = "PASSWORD", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)
于 2014-03-11T22:02:43.250 回答