sendmail: Send Emails

View source: R/sendmail.R

sendmailR Documentation

Send Emails

Description

Send emails via command line tools.

Usage

sendmail(subject, body, body.file = NULL, to = NULL, from,
         cc = NULL, bcc = NULL, replyto = NULL,
         server, port, user, password,
         attach = NULL, signature = NULL, signature.file = NULL,
         headers = NULL, wait = TRUE, logfile = NULL,
         encoding = "unknown", method = NULL,
         display.only = FALSE, html = FALSE, tls = NULL,
         SendUsingAccount)

Arguments

subject

character

body

character. When of length > 1, then all elements are pasted together, separated by newline characters

body.file

character. If specified, body is ignored.

to

character

from

character

cc

character

bcc

character

replyto

character

server

character

port

character (an integer will automatically be coerced). Typically 587.

user

character

password

character

attach

character

signature

character

signature.file

character. Name of file.

headers

a character vector of header lines (i.e. for more than one header use c(....))

wait

logical

logfile

character

encoding

character

method

the programme to be called. Supported are sendemail, blat and outlook. Method outlook is supported only on Windows, where it also requires PowerShell.

display.only

logical: if TRUE, only display message, but do not send. Works only for method outlook.

html

logical: send as HTML? For method sendemail, if the message body begins with <html>, it is considered HTML.

tls

NULL or length-one logical: use TLS? Only used for method sendemail. If NULL, sendemail's default settings are used.

SendUsingAccount

a character string: an email address. only supported for method ‘outlook’.

Details

The function provides a wrapper for different tools that send emails. In this way, the same R code that can be used across platforms, provided a suitable backend is installed.

The function constructs an invocation of a command-line utility, specified by method, and then calls the specified method via system. Currently supported are sendemail, Blat and Outlook (see References).

Value

the return value of system

Author(s)

Enrico Schumann

References

http://caspian.dotconf.net/menu/Software/SendEmail/ https://www.blat.net/

RFC 2822: Internet Message Format. https://tools.ietf.org/html/rfc2822

Examples

## Not run: 
body <- "
<p>Hello.</p>

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

sendmail(subject  = "Greetings",
         body     = "Hello",
         to       = "testing@testing.org",
         method   = "outlook",
         html     = TRUE,
         display.only = TRUE)  ## only open mail in Outlook

## End(Not run)

enricoschumann/mailtools documentation built on Oct. 27, 2023, 8:14 p.m.