微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用mailR通过R发送邮件

如何解决使用mailR通过R发送邮件

不确定为什么这对我不起作用。当然,我没有设置其他任何东西。在运行此程序之前,我需要在gmail中进行任何设置吗?

library(mailR)

send.mail(from="xxxx@gmail.com",to="xxxx@yahoo.com",subject="Test Email",body="PFA the desired document",html=T,smtp=list(host.name = "smtp.gmail.com",port = 465,user.name = "xxxx@gmail.com",passwd = "xxxxxxx",ssl = T),authenticate=T)

这是我得到的错误

org.apache.commons.mail.EmailException: Sending the email to the following server Failed : 
smtp.gmail.com:465
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
    at org.apache.commons.mail.Email.send(Email.java:1437)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(UnkNown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnkNown Source)
    at java.lang.reflect.Method.invoke(UnkNown Source)
    at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. 
 Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials k64sm13557042qkc.97 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
at 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 more
NULL
Error: EmailException (Java): Sending the email to the following server Failed : smtp.gmail.com:465

即使说我的用户名和密码不正确,我还是检查并输入了

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。