Skip to content

enricoschumann/mailtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mailtools

Usage: Sending Emails

A typical call may look as follows.

library("mailtools")
sendmail(subject  = "Greetings",
	   body     = "Hello",
	   to       = "[email protected]",
	   from     = "<[email protected]>",
	   port     = 123,
	   server   = "my-magic-server.net",
	   user     = "username",
	   password = "1234.password",
	   headers  = "X-GREETINGS-CATEGORY: hello",
	   method   = c(unix = "sendemail",
			windows = "blat")[.Platform$OS.type])

On Windows, you may prefer method outlook (which requires Outlook and PowerShell installed).

sendmail(subject  = "Greetings",
         body     = "Hello",
         to       = "[email protected]",
         method   = "outlook",
         display.only = TRUE)  ## only open mail in Outlook

Formating message texts is possible via HTML. (Note that R supports multi-line strings.)

body <- "
<p>Hello.</p>
<p>Please do not send <b>spam</b>.</p>
"

sendmail(subject  = "Greetings",
	   body     = body,
	   to       = "[email protected]",
	   method   = "outlook",
	   html     = TRUE,
	   display.only = TRUE)

(But note that none of the backends will automatically create a text part for your message. In the good old days, a message with an HTML part but no text part was often more likely to be flagged as spam. But these days it seems to be the norm. Oh well. You have been warned, in any case.)

Installation

The latest version of the package is available from http://enricoschumann.net/R/packages/mailtools. You can install the package directly from within R:

install.packages('mailtools',
                 repos = c('http://enricoschumann.net/R', 
                           getOption('repos')))

Note that the package itself does not provide code for actually sending emails. For this, you’ll need a backend.

On GNU/Linux systems, there is support for =sendemail=. On Debian/Ubuntu systems, for instance, it is easily installed:

sudo apt install sendemail

On Windows, the preferred backend is Blat. Alternatively, provided PowerShell is installed (which is the default case on newer Windows systems), you may use Outlook.

There is also a publicly-available repository at https://github.com/enricoschumann/mailtools.

About

R utilities for handling email

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages