我正在尝试使用mailR
软件包和gmail从RStudio发送电子邮件。以下是我的代码......
library(mailR)
sender <- "xxxxx@gmail.com"
recipients <- c("xxxxx@gmail.com")
send.mail(from = sender,
to = recipients,
subject = "Test mail from Rstudio",
body = "Test email body",
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "xxxxx@gmail.com",
passwd = "******", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
我收到以下错误消息...
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: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuu
534-5.7.14 XIuKGOx55rNHFSvDWkzr2B1augfG-Z1zGTYEQ9IZ-iD_aDivhY0aUWNjt0C4ckYrqyx0WS
534-5.7.14 Zbz-1z65Xz8C1irD5crNwDSpgL3qQGgo6V-PvkiA6h1on6Hnn-YjSeho0uBWcG59x1C4TH
534-5.7.14 F6ZM2i2TToB9tIjzoUv_3encd3EW0Aw04XBaTVkoWseyUOaTTvglnCIj23ZNrIncqXW0f5
534-5.7.14 gjMKNtrSAOBmJxrgnXGrRS2BC9y9Q> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 t62sm25604268pfa.38 - 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
Error: EmailException (Java): Sending the email to the following server failed : smtp.gmail.com:465
我到底做错了什么?错误消息中提到的Google链接不存在。
编辑:收到谷歌发来的电子邮件,说'禁止登录尝试:有人试图从不符合现代安全标准的应用登录...'有解决方法吗?谷歌电子邮件没有说允许我从R发送消息。
答案 0 :(得分:13)
在此处启用对“安全性较低的应用”的访问权限:
答案 1 :(得分:1)
我已仔细阅读此主题和其他主题。我下载了正确的 Java(64 位),java env 的路径是正确的,没有在 gmail 上设置 2FA,“不太安全的应用程序”访问是打开的,但既不是通过 SSL + 端口 465 也不是通过 TLS + 端口 587 am i能够发送电子邮件,我收到了与上述内容和其他问题线程类似的错误,这些错误似乎可以通过 2FA 问题或“不太安全的应用程序”问题解决 - 这个问题似乎不同......真的很感激这方面的一些帮助,已经在上面花了几个小时,但无处可去。
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.invokeMetNULL
hod(RJavaTools.java:386)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2055)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
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
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at sun.security.ssl.HandshakeContext.<init>(Unknown Source)
at sun.security.ssl.ClientHandshakeContext.<init>(Unknown Source)
at sun.security.ssl.TransportContext.kickstart(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:215)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
... 13 more
Error: EmailException (Java): Sending the email to the following server failed : smtp.gmail.com:465