mailR:向服务器发送电子邮件失败

时间:2019-07-25 12:34:09

标签: r email

我正在尝试使用mailR软件包发送电子邮件。我可以在家中通过个人计算机和Internet进行此操作,但不能在办公室中安装和管理防火墙,防病毒等功能的公司上班。尝试时,我得到了 较长的错误消息,结尾为:

  

错误:EmailException(Java):将电子邮件发送到以下服务器失败:smtp.gmail.com:465

我将在此问题的底部粘贴完整的错误消息。

我正在使用的代码如下:

send.mail(from="MyEmail@gmail.com",
          to="MyOtherEmail@hotmail.com",
          subject="Test Email",
          body="Test body",
          html=T,
          smtp=list(host.name = "smtp.gmail.com",
                    port = 465, #587,
                    user.name = "MyEmail@gmail.com",
                    passwd = "xxxx",
                    ssl=T), #tls = T),
          authenticate=T,
          debug=T)

在阅读了一些类似的问题之后,我尝试将端口更改为587,同时使用tls=T而不是ssl=T。我已经在我的google帐户上启用了安全性较低的应用程序,并且没有启用“两因素”身份验证,但是我认为问题与我的google帐户无关,因为该代码可在家中工作。我没有关闭防病毒软件的选项,这是公司控制的,对我而言是不可能的。 使用Debug中的send.mail选项,最后一行是我想出现问题的地方:

  

调试SMTP:尝试连接到主机“ smtp.gmail.com”,端口465,isSSL为假

关于防火墙和防病毒方面的限制,有人对我如何从R处获得电子邮件通知以使我知道脚本已完成运行以及结果如何有任何想法吗?对于使用mailR包,我并不挑剔-我也按照本文中的建议尝试了mail

sending mail from R (mailR)

具有以下代码:

sendmail("MyEmail@gmail.com", "mail of R", "Testing!")

但是,我收到以下错误消息:

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open URL 'http://rmail.linhi.de/rmail.php?Email=MyEmail@gmail.com&Passwort=rmail&Betreff=mail<of<R&Nachricht=Testing!': HTTP status was '404 Not Found'

Here is the full Debug result and error message I get using send.mail:
>DEBUG: JavaMail version 1.5.2
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false
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: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout 60000;
  nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2053)
    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: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:310)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:215)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
    ... 13 more

0 个答案:

没有答案