通过R发送电子邮件

时间:2016-08-23 05:54:11

标签: r email

我正在使用mailR包通过R发送电子邮件我正在使用以下代码

send.mail(from = "xyz@gmail.com",
      to = c("abc@hotmail.com"),
      #replyTo = c("Reply to someone else <someone.else@gmail.com>")
      subject = "Hi",
      body = "Hi",
      smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "xyz", passwd = "", ssl = TRUE),
      authenticate = TRUE,
      send = TRUE)

当我运行此代码时,我收到以下错误。

  

错误:EmailException(Java):将电子邮件发送到以下内容   服务器失败:smtp.gmail.com:465       org.apache.commons.mail.EmailException:将电子邮件发送到以下服务器失败:smtp.gmail.com:465 at   org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)at at   org.apache.commons.mail.Email.send(Email.java:1437)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:606)at   RJavaTools.invokeMethod(RJavaTools.java:386)       引起:javax.mail.AuthenticationFailedException:534-5.7.14请通过您的网络浏览器登录       534-5.7.14然后再试一次。       534-5.7.14了解更多信息       534 5.7.14 https://support.google.com/mail/answer/78754 191sm1808499pfx.68 - gsmtp

     

在   com.sun.mail.smtp.SMTPTransport $ Authenticator.authenticate(SMTPTransport.java:892)     在   com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814)     在   com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)     在javax.mail.Service.connect(Service.java:386)at   javax.mail.Service.connect(Service.java:245)at   javax.mail.Service.connect(Service.java:194)at   javax.mail.Transport.send0(Transport.java:253)at   javax.mail.Transport.send(Transport.java:124)at   org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)... 6   更

是否因为某些安全原因gmail阻止访问?我该如何摆脱它?

0 个答案:

没有答案