RJython通过.bat防火墙发送邮件

时间:2015-08-27 12:24:36

标签: r email batch-file jython

我们有.bat文件调用R脚本并生成一些数据,然后通过rJython向某些用户发送电子邮件。

如果我在RStudio中运行此脚本,一切顺利,邮件将被发送。但是,如果我调用.bat文件,我们会收到以下错误。

它可能与我们公司的防火墙有关,有人可以帮助我们吗?我们需要告诉我们的IT部门,他们也无法帮助我们。

Error in jython.exec(rJython,mail): (-1, 'Unmapped exception:java.net.SocketException: Permission denied: connect') Execution halted

发送邮件的R-Code是:

#Sendmail Code
rJython<-rJython()
rJython$exec("import smtplib")
rJython$exec("from email.MIMEText import MIMEText")
rJython$exec("import email.utils")
rJython$exec("COMMASPACE = ', '")

recipients_string_j = paste("toaddrs  = [",recipients_string,"]",sep="")

#mail config
mail<-c( fromaddr = 'test@XXX.com", 
  recipients_string_j, 
  paste("msg = MIMEText('",data.frame,"','html')",sep="",collapse=""),
  paste("msg['Subject'] = 'DUMMY SUBJECT'"),
  "msg['From'] = fromaddr",
  "msg['To']= COMMASPACE.join(toaddrs)",
  "server = smtplib.SMTP('00.00.00.000')", 
  "server.sendmail(fromaddr, toaddrs, msg.as_string())", 
  "server.quit()") 


#send mail
jython.exec(rJython,mail)

0 个答案:

没有答案