Hi all, I thought I would post code to send an email out of R. The code uses Grothendieck and Bellosta's interface package rJython for executing Python from R. The code itself provides basic email functionality for email servers requiring authentication. It should be easy to extend it (e.g., for sending attachments). I hope it's useful.
require(rJython) rJython <- rJython() rJython$exec( "import smtplib" ) rJython$exec("from email.MIMEText import MIMEText") rJython$exec("import email.utils") mail<-c( #Email settings "fromaddr = 'sender email address'", "toaddrs = 'recipient email address'", "msg = MIMEText('This is the body of the message.')", "msg['From'] = email.utils.formataddr(('sender name', fromaddr))", "msg['To'] = email.utils.formataddr(('recipient name', toaddrs))", "msg['Subject'] = 'Simple test message'", #SMTP server credentials "username = 'sender login'", "password = 'sender password'", #Set SMTP server and send email, e.g., google mail SMTP server "server = smtplib.SMTP('smtp.gmail.com:587')", "server.ehlo()", "server.starttls()", "server.ehlo()", "server.login(username,password)", "server.sendmail(fromaddr, toaddrs, msg.as_string())", "server.quit()") jython.exec(rJython,mail) Best, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Email-out-of-R-code-tp3530671p3530671.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.