gpt4 book ai didi

r - 使用 mailR 通过 Gmail 发送电子邮件时出错

转载 作者:行者123 更新时间:2023-12-04 03:19:41 29 4
gpt4 key购买 nike

我正在尝试使用 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

我到底做错了什么?错误消息中提到的谷歌链接不存在。

编辑:收到一封来自谷歌的电子邮件,内容是“登录尝试被阻止:有人试图从不符合现代安全标准的应用程序登录......”

有没有解决的办法?谷歌电子邮件没有说明允许我从 R 发送消息。

最佳答案

在此处启用对“安全性较低的应用程序”的访问:

http://www.google.com/settings/security/lesssecureapps

关于r - 使用 mailR 通过 Gmail 发送电子邮件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37343074/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com