AppenderSendmail {lgrExtra} | R Documentation |
Send emails via sendmailR
Description
Send mails via sendmailR::sendmail()
, which requires that you have access
to an SMTP server that does not require authentication. This
Appender keeps an in-memory buffer like AppenderBuffer. If the buffer is
flushed, usually because an event of specified magnitude is encountered, all
buffered events are concatenated to a single message. The default behavior
is to push the last 30 log events in case a fatal
event is encountered.
Value
The $new()
method returns an R6::R6 that inherits from
lgr::Appender and can be uses as an appender by a lgr::Logger.
Super classes
lgr::Filterable
-> lgr::Appender
-> lgr::AppenderMemory
-> lgrExtra::AppenderDigest
-> lgrExtra::AppenderMail
-> AppenderSendmail
Active bindings
control
headers
Methods
Public methods
Inherited methods
lgr::Filterable$add_filter()
lgr::Filterable$filter()
lgr::Filterable$remove_filter()
lgr::Filterable$set_filters()
lgr::Appender$set_layout()
lgr::Appender$set_threshold()
lgr::AppenderMemory$append()
lgr::AppenderMemory$clear()
lgr::AppenderMemory$set_buffer_size()
lgr::AppenderMemory$set_flush_on_exit()
lgr::AppenderMemory$set_flush_on_rotate()
lgr::AppenderMemory$set_flush_threshold()
lgr::AppenderMemory$set_should_flush()
lgr::AppenderMemory$show()
lgrExtra::AppenderDigest$set_subject_layout()
lgrExtra::AppenderMail$format()
lgrExtra::AppenderMail$set_bcc()
lgrExtra::AppenderMail$set_cc()
lgrExtra::AppenderMail$set_from()
lgrExtra::AppenderMail$set_html()
lgrExtra::AppenderMail$set_to()
Method new()
see AppenderMail for details
Usage
AppenderSendmail$new( to, control, threshold = NA_integer_, flush_threshold = "fatal", layout = LayoutFormat$new(fmt = " %L [%t] %m %f", timestamp_fmt = "%H:%M:%S"), subject_layout = LayoutFormat$new(fmt = "[LGR] %L: %m"), buffer_size = 29, from = get_user(), cc = NULL, bcc = NULL, html = FALSE, headers = NULL, filters = NULL )
Method flush()
Usage
AppenderSendmail$flush()
Method set_control()
Usage
AppenderSendmail$set_control(x)
Method set_headers()
Usage
AppenderSendmail$set_headers(x)
Note
The default Layout's fmt
indents each log entry with 3 blanks. This
is a workaround so that Microsoft Outlook does not mess up the line breaks.
See Also
Other Appenders:
AppenderDbi
,
AppenderDt
,
AppenderElasticSearch
,
AppenderGmail
,
AppenderPushbullet
,
AppenderSyslog
Other Digest Appenders:
AppenderDigest
,
AppenderMail
,
AppenderPushbullet
Examples
## Not run:
lgr::AppenderSendmail$new(
to = "user@ecorp.com",
control = list(smtpServer = "mail.ecorp.com"),
from = "lgr_user@yourmail.com"
)
## End(Not run)
if (requireNamespace("sendmailR")){
# requires that you have access to an SMTP server
lg <- lgr::get_logger("lgrExtra/test/mail")$
set_propagate(FALSE)$
add_appender(AppenderSendmail$new(
from = "ceo@ecorp.com",
to = "some.guy@ecorp.com",
control = list(smtpServer = "mail.somesmptserver.com")
))
# cleanup
invisible(lg$config(NULL))
}