我正在尝试测试使用mailR包从R发送电子邮件,但我不断收到我不明白的错误消息。我浏览了是否有任何现有的解决方案,但未能找到解决方案。
我还测试了使用port = 25到telnet运行相同的smtp主机,并且通过telnet连接到smtp服务器看起来很好。因此,端口和smtp主机似乎不是问题。当我因某种原因跑到R时,它只会成为一个问题。有人可以帮助解释这里的错误吗?非常感谢。
命令:
send.mail(from = "abc@company.com",
to = "xyz@company.com",
subject = "Hello this is a testing message",
body = "And this is a body text",
smtp = list(host.name = "mailhub.company.com",port=25),
authenticate = FALSE,
send = TRUE,debug=TRUE)
错误:
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: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "mailhub.company.com", port 25, isSSL false
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
进一步调试显示:
8: .jrcall(x, name, ...)
9: .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/Object"), .jnew("java/lang/String", method), j_p, j_pc, use.true.class = TRUE, evalString = simplify, evalArray = FALSE)
10: .jcheck(silent = FALSE)
11: stop(list(message = "org.apache.commons.mail.EmailException: Sending the email to the following server failed : mailhub.company.com:25", call = .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/
12: conditionMessage(cond)
13: conditionMessage.condition(cond)
14: c$message
15: `$.Throwable`(c, "message")
但是我无法弄清楚为什么当端口和smtp信息正确时,发送到指定的smtp主机的电子邮件无法正常工作。