title: Unable to send an email from R using mailR package (Error in ls(envir = envir, all.names = private))
body: <p>I am trying to test sending an email from R with mailR package, but I keep getting such error message which I do not understand. I browsed around if there's any existing solution, but failed to find one.</p>
  
  <p>I also tested running the same smtp host with port =25 thru telnet and connection to smtp server looks fine via telnet. So, port and smtp host doesn't seem to be an issue. It only becomes an issue when I run thru R for some reason. Can someone help interpreting the error here? Greatly appreciate.</p>
  
  <p><strong>Command:</strong></p>
  
  <pre><code>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)
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Further Debugging shows:</strong></p>
  
  <pre><code>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")
  </code></pre>
  
  <p>But I am unable to figure out why sendin email to the assigned smtp host is not working correctly while port and smtp information are correct.</p>