[R] Email out of R (code)

From: Wolfgang RAFFELSBERGER <wraff_at_igbmc.fr>
Date: Wed, 18 May 2011 16:29:08 +0000

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.

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. Received on Wed 18 May 2011 - 17:39:34 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 May 2011 - 17:40:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive