[R] Email out of R (code)

Wolfgang RAFFELSBERGER wraff at igbmc.fr
Wed May 18 18:29:08 CEST 2011


In case you're using Unix/Linux, have a look at
www.r-project.org/doc/Rnews/Rnews_2007-1.pdf
(page 30 - 32)

Wolfgang

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
IGBMC,
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300         Fax (+33) 388 65 3276
wolfgang.raffelsberger (a t) igbmc.fr

________________________________________
De : r-help-bounces at r-project.org [r-help-bounces at r-project.org] de la part de Kevin Wright [kw.stat at gmail.com]
Date d'envoi : mercredi 18 mai 2011 17:57
À : Daniel Malter
Cc : r-help at r-project.org
Objet : Re: [R] Email out of R (code)

How does this compare to create.post() ?

Kevin


On Tue, May 17, 2011 at 3:44 PM, Daniel Malter <daniel at umd.edu> wrote:

> 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 at 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help at 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.



More information about the R-help mailing list