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 |
Create a MIME part
mime_part(x, name, ...)
mime_part(x, name, ...)
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 |
An S3 mime_part
object.
mime_part.character
, mime_part_html
,
mime_part.data.frame
, mime_part.matrix
,
mime_part.ggplot
, mime_part.trellis
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.
mime_part_html(x, ...)
mime_part_html(x, ...)
x |
Character string, vector/list of character strings or path to html file. |
... |
Ignored. |
An S3 mime_part
object.
## 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)
## 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 a MIME part from a character string. If the string matches a filename, a MIME part containing that file is returned instead.
## S3 method for class 'character' mime_part(x, name, type, flowed = FALSE, ...)
## S3 method for class 'character' mime_part(x, name, type, flowed = FALSE, ...)
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. |
An S3 mime_part
object.
mime_part_html
for adding inline HTML
data.frame
.Create a MIME part from a data.frame
.
## S3 method for class 'data.frame' mime_part(x, name = deparse(substitute(x)), filename_extension = ".txt", ...)
## S3 method for class 'data.frame' mime_part(x, name = deparse(substitute(x)), filename_extension = ".txt", ...)
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. |
An S3 mime_part
object.
Creates a string representation of the object x
using
dput
. This representation is then turned into a file
attachment.
## Default S3 method: mime_part(x, name, ...)
## Default S3 method: mime_part(x, name, ...)
x |
R object |
name |
Filename used for attachment (sans the .R extension) |
... |
Ignored. |
An S3 mime_part
object.
Writes a PDF file of the plot defined by x
and turns this
PDF file into a file attachment.
## S3 method for class 'ggplot' mime_part(x, name = deparse(substitute(x)), device = pdf, ...)
## S3 method for class 'ggplot' mime_part(x, name = deparse(substitute(x)), device = pdf, ...)
x |
A |
name |
Name of attachment (sans .pdf extension). |
device |
Graphics device used to render the plot. Defaults to
|
... |
Ignored. |
An S3 mime_part
object.
Create a MIME part from a matrix.
## S3 method for class 'matrix' mime_part(x, name = deparse(substitute(x)), ...)
## S3 method for class 'matrix' mime_part(x, name = deparse(substitute(x)), ...)
x |
Matrix |
name |
Basename of file attachment that is generated. |
... |
Ignored. |
An S3 mime_part
object
Writes a PDF file of the plot defined by x
and turns this
PDF file into a file attachment.
## S3 method for class 'trellis' mime_part(x, name = deparse(substitute(x)), device = pdf, ...)
## S3 method for class 'trellis' mime_part(x, name = deparse(substitute(x)), device = pdf, ...)
x |
A |
name |
Name of attachment (sans .pdf extension). |
device |
Graphics device used to render the plot. Defaults to
|
... |
Ignored. |
An S3 mime_part
object.
Simplistic sendmail utility for R. Uses SMTP to submit a message to a local SMTP server.
sendmail( from, to, subject, msg, cc, bcc, ..., engine = c("internal", "curl", "debug"), headers = list(), control = list(), engineopts = list() )
sendmail( from, to, subject, msg, cc, bcc, ..., engine = c("internal", "curl", "debug"), headers = list(), control = list(), engineopts = list() )
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.
|
mime_part
for a way to add attachments.
curl::send_mail
for curl SMTP URL specification.
## 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)
## 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)
Specify global sendmail options so that subsequent calls to
sendmail()
do not have to set them in the control
argument.
sendmail_options(...) sendmailOptions(...)
sendmail_options(...) sendmailOptions(...)
... |
Any options can be defined, using |
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.
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).
Olaf Mersmann [email protected]