Learn R Programming

ParallelLogger (version 3.0.0)

createEmailAppender: Create e-mail appender

Description

Create e-mail appender

Usage

createEmailAppender(
  layout = layoutEmail,
  mailSettings,
  label = Sys.info()["nodename"],
  test = FALSE
)

Arguments

layout

The layout to be used by the appender.

mailSettings

Arguments to be passed to the send.mail function in the mailR package (except subject and body).

label

A label to be used in the e-mail subject to identify a run. By default the name of the computer is used.

test

If TRUE, a message will be displayed on the console instead of sending an e-mail.

Details

Creates an appender that will send log events to an e-mail address using the mailR package. Please make sure your settings are correct by using the mailR package before using those settings here. ParallelLogger will not display any messages if something goes wrong when sending the e-mail.

Examples

Run this code
# NOT RUN {
mailSettings <- list(
  from = "someone@gmail.com",
  to = c("someone_else@gmail.com"),
  smtp = list(
    host.name = "smtp.gmail.com",
    port = 465,
    user.name = "someone@gmail.com",
    passwd = "super_secret!",
    ssl = TRUE
  ),
  authenticate = TRUE,
  send = TRUE
)
# Setting test to TRUE in this example so we don't really send an e-mail:
appender <- createEmailAppender(
  layout = layoutEmail,
  mailSettings = mailSettings,
  label = "My R session",
  test = TRUE
)

logger <- createLogger(name = "EMAIL", threshold = "FATAL", appenders = list(appender))
registerLogger(logger)

logFatal("Something bad")

unregisterLogger("EMAIL")
# }

Run the code above in your browser using DataLab