AppenderSendmail.Rd
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.
The $new()
method returns an R6::R6 that inherits from
lgr::Appender and can be uses as an appender by a lgr::Logger.
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.
LayoutFormat, LayoutGlue
Other Appenders:
AppenderDbi
,
AppenderDt
,
AppenderElasticSearch
,
AppenderGmail
,
AppenderPushbullet
,
AppenderSyslog
Other Digest Appenders:
AppenderDigest
,
AppenderMail
,
AppenderPushbullet
lgr::Filterable
-> lgr::Appender
-> lgr::AppenderMemory
-> lgrExtra::AppenderDigest
-> lgrExtra::AppenderMail
-> AppenderSendmail
control
headers
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()
new()
see AppenderMail for details
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
)
flush()
if (FALSE) {
lgr::AppenderSendmail$new(
to = "user@ecorp.com",
control = list(smtpServer = "mail.ecorp.com"),
from = "lgr_user@yourmail.com"
)
}
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))
}