错误:EmailException(Java):将电子邮件发送到以下服务器失败:127.0.0.1:3883

时间:2018-03-23 08:30:49

标签: r

我正在尝试使用以下代码发送邮件,但我收到的错误如下所示: 谁能告诉我如何克服这个错误?

是因为我连接的服务器还是有其他原因导致此错误?

     > library(sendmailR)
       library(mailR)
       send.mail(from = "x@company.com",
                  to = c("y@company.com"),
                  #cc = c("CC Recipient <cc.recipient@gmail.com>"),
                  #bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
                  subject = "Subject of the email",
                  body = "Body of the email",
                  smtp = list(host.name = "127.0.0.1", port = 3838),
                  authenticate = FALSE,
                  send = TRUE)

当我运行上面的代码时,我得到以下输出错误:

        org.apache.commons.mail.EmailException: Sending the email to the following server failed : 127.0.0.1:3838
            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: 127.0.0.1, 3838; timeout 60000;
          nested exception is:
            java.net.ConnectException: Connection refused: 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:364)
            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 refused: 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 com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:310)
            at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
            at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
            ... 13 more
        NULL

        **Error: EmailException (Java): Sending the email to the following server failed : 127.0.0.1:3838**

0 个答案:

没有答案