Package 'sendmailR'

Title: Send Email Using R
Description: Package contains a simple SMTP client with minimal dependencies which provides a portable solution for sending email, including file attachments and inline html reports, from within R. SMTP Authentication and SSL/STARTTLS is implemented using curl.
Authors: Olaf Mersmann [aut, cre] , Quinn Weber [ctb], Marius Barth [ctb] , Are Edvardsen [ctb] , Alexander Bartel [ctb]
Maintainer: Olaf Mersmann <[email protected]>
License: GPL-2
Version: 1.4-0
Built: 2024-11-02 02:56:28 UTC
Source: https://github.com/olafmersmann/sendmailr

Help Index


Create a MIME part

Description

Create a MIME part

Usage

mime_part(x, name, ...)

Arguments

x

Object to include

name

Name of mime part. Usually the filename of the attachment as displayed by the e-mail client.

...

Possible further arguments for mime_part implementations.

Value

An S3 mime_part object.

See Also

mime_part.character, mime_part_html, mime_part.data.frame, mime_part.matrix, mime_part.ggplot, mime_part.trellis


Create an inline HTML MIME Part

Description

Create a MIME part from a character string containing HTML. If the string matches a filename the file is read and inserted as an inline character MIME part.

Usage

mime_part_html(x, ...)

Arguments

x

Character string, vector/list of character strings or path to html file.

...

Ignored.

Value

An S3 mime_part object.

Examples

## Not run: 
sendmail(
  from="[email protected]",
  to="[email protected]",
  subject="inline HTML",
  msg=mime_part_html("Hello<br>World"),
  control=list(smtpServer="ASPMX.L.GOOGLE.COM")
)

sendmail(
  from="[email protected]",
  to="[email protected]",
  subject="inline HTML",
  msg=mime_part_html("out/report.html"),
  control=list(smtpServer="ASPMX.L.GOOGLE.COM")
)

## End(Not run)

Create an inline character MIME Part

Description

Create a MIME part from a character string. If the string matches a filename, a MIME part containing that file is returned instead.

Usage

## S3 method for class 'character'
mime_part(x, name, type, flowed = FALSE, ...)

Arguments

x

Character string, possibly a filename.

name

Name of attachment.

type

Content type of inline text. Defaults to "text/plain" for character strings and to "application/octet-stream" for files.

flowed

Should "format=flowed" be added to the content header.

...

Ignored.

Value

An S3 mime_part object.

See Also

mime_part_html for adding inline HTML


Create a MIME part from a data.frame.

Description

Create a MIME part from a data.frame.

Usage

## S3 method for class 'data.frame'
mime_part(x, name = deparse(substitute(x)), filename_extension = ".txt", ...)

Arguments

x

A data.frame.

name

Basename of file attachment that is generated.

filename_extension

Filename extension (i.e., the suffix) to be used for the attached file.

...

Ignored.

Value

An S3 mime_part object.


Default MIME part method

Description

Creates a string representation of the object x using dput. This representation is then turned into a file attachment.

Usage

## Default S3 method:
mime_part(x, name, ...)

Arguments

x

R object

name

Filename used for attachment (sans the .R extension)

...

Ignored.

Value

An S3 mime_part object.


Creates a MIME part from a ggplot2 plot object

Description

Writes a PDF file of the plot defined by x and turns this PDF file into a file attachment.

Usage

## S3 method for class 'ggplot'
mime_part(x, name = deparse(substitute(x)), device = pdf, ...)

Arguments

x

A ggplot object

name

Name of attachment (sans .pdf extension).

device

Graphics device used to render the plot. Defaults to pdf.

...

Ignored.

Value

An S3 mime_part object.


Create a MIME part from a matrix.

Description

Create a MIME part from a matrix.

Usage

## S3 method for class 'matrix'
mime_part(x, name = deparse(substitute(x)), ...)

Arguments

x

Matrix

name

Basename of file attachment that is generated.

...

Ignored.

Value

An S3 mime_part object


Creates a MIME part from a trellis plot object

Description

Writes a PDF file of the plot defined by x and turns this PDF file into a file attachment.

Usage

## S3 method for class 'trellis'
mime_part(x, name = deparse(substitute(x)), device = pdf, ...)

Arguments

x

A trellis (lattice) object

name

Name of attachment (sans .pdf extension).

device

Graphics device used to render the plot. Defaults to pdf.

...

Ignored.

Value

An S3 mime_part object.


Send mail from within R

Description

Simplistic sendmail utility for R. Uses SMTP to submit a message to a local SMTP server.

Usage

sendmail(
  from,
  to,
  subject,
  msg,
  cc,
  bcc,
  ...,
  engine = c("internal", "curl", "debug"),
  headers = list(),
  control = list(),
  engineopts = list()
)

Arguments

from

From whom the mail message is (RFC2822 style address).

to

Recipient of the message (vector of valid RFC2822 style addresses).

subject

Subject line of message.

msg

Body text of message or a list containing mime_part objects.

cc

Carbon-copy recipients (vector of valid RFC2822 style addresses).

bcc

Blind carbon-copy recipients (vector of valid RFC2822 style addresses).

...

...

engine

One of:

  • "internal" for the internal smtp transport (default).

  • "curl" for the use of curl for transport. Enable if you need STARTTLS/SSL and/or SMTP authentication. See curl::send_mail.

  • "debug" sendmail returns a RFC2822 formatted email message without sending it.

headers

Any other headers to include.

control

List of SMTP server settings. Valid values are the possible options for sendmail_options.

engineopts

Options passed to curl if using the curl backend.

  • For authentication pass a list with username and password.

  • use_ssl defaults to "force" if unset.

  • For available options run curl::curl_options.

See Also

mime_part for a way to add attachments.

curl::send_mail for curl SMTP URL specification.

Examples

## Not run: 
from <- sprintf("<sendmailR@\\%s>", Sys.info()[4])
to <- "<[email protected]>"
subject <- "Hello from R"
body <- list("It works!", mime_part(iris))
sendmail(from, to, subject, body,
         control=list(smtpServer="ASPMX.L.GOOGLE.COM"))

sendmail(from="[email protected]",
  to=c("[email protected]", "[email protected]"),
  subject="SMTP auth test",
  msg=mime_part("This message was send using sendmailR and curl."),
  engine = "curl",
  engineopts = list(username = "foo", password = "bar"),
  control=list(smtpServer="smtp://smtp.gmail.com:587", verbose = TRUE)
)

## End(Not run)

Set package specific options.

Description

Specify global sendmail options so that subsequent calls to sendmail() do not have to set them in the control argument.

Usage

sendmail_options(...)

sendmailOptions(...)

Arguments

...

Any options can be defined, using name=value or by passing a list of such tagged values. However, only the ones below are used in base sendmailR.

Details

List of options:

  • smtpServerSMTP server to contact. This can either be the mail server responsible for the destination addresses domain or a smarthost provided by your ISP or institution. SMTP AUTH is currently unsupported.

  • smtpPortSMTP port to use. Usually 25 but some institutions require the use of the submission service (port 587).

  • verboseShow detailed information about message submission. Useful for debugging.

Value

For sendmail_options(), a list of all set options sorted by name. For sendmail_options(name), a list of length one containing the set value, or 'NULL' if it is unset. For uses setting one or more options, a list with the previous values of the options changed (returned invisibly).

Author(s)

Olaf Mersmann [email protected]