Version: | 1.4-0 |
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. |
URL: | https://github.com/olafmersmann/sendmailR |
BugReports: | https://github.com/olafmersmann/sendmailR/issues |
Depends: | R (≥ 3.0.0) |
Imports: | base64enc |
Suggests: | curl (≥ 4.0), knitr, rmarkdown, htmltools |
License: | GPL-2 |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2023-01-11 18:18:37 UTC; olafm |
Author: | Olaf Mersmann |
Maintainer: | Olaf Mersmann <olafm@p-value.net> |
Repository: | CRAN |
Date/Publication: | 2023-01-12 09:30:02 UTC |
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 |
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 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 = "text/plain", flowed = FALSE, ...)
Arguments
x |
Character string, possibly a filename. |
name |
Name of attachment. |
type |
Content type of inline text. Defaults to "text/plain". |
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 |
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 |
name |
Name of attachment (sans .pdf extension). |
device |
Graphics device used to render the plot. Defaults to
|
... |
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 |
name |
Name of attachment (sans .pdf extension). |
device |
Graphics device used to render the plot. Defaults to
|
... |
Ignored. |
Value
An S3 mime_part
object.
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="from@example.org",
to="to1@example.org",
subject="inline HTML",
msg=mime_part_html("Hello<br>World"),
control=list(smtpServer="ASPMX.L.GOOGLE.COM")
)
sendmail(
from="from@example.org",
to="to1@example.org",
subject="inline HTML",
msg=mime_part_html("out/report.html"),
control=list(smtpServer="ASPMX.L.GOOGLE.COM")
)
## End(Not run)
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
|
cc |
Carbon-copy recipients (vector of valid RFC2822 style addresses). |
bcc |
Blind carbon-copy recipients (vector of valid RFC2822 style addresses). |
... |
... |
engine |
One of:
|
headers |
Any other headers to include. |
control |
List of SMTP server settings. Valid values are the
possible options for |
engineopts |
Options passed to curl if using the curl backend.
|
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 <- "<olafm@datensplitter.net>"
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="from@example.org",
to=c("to1@example.org", "to2@example.org"),
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 |
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 olafm@datensplitter.net