I try to check the sending of email from R using the mailR package, but I keep getting an error message that I donβt understand. I looked if there is an existing solution, but did not find it.
I also tested starting the same smtp host with port = 25 via telnet, and the connection to the smtp server looked great through telnet. So the port and smtp host does not seem to be a problem. It only becomes a problem when I run through R for some reason. Can anyone help interpret the error here? I really appreciate it.
Command:
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)
Error:
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
Further debugging shows:
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")
But I canβt understand why sendin email for the designated smtp host does not work correctly as long as the port and smtp information is correct.