使用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 (将#修改为@)