Send (authenticated) email from your router using EEM
event manager environment _email_to noc@isp.com
event manager environment _email_server usr:pwd@mail.isp.com
event manager environment _email_from usr@isp.com
action 1.0 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "$_event_pub_time: Login via SSH" body "$_syslog_msg"
action 1.5 syslog msg priority 5 "Mail Sent"
Send email from your router using EEM
EEM Send e-mail after a router reload
For example, to execute an EEM applet that will send an e-mail twenty seconds after the router reload, you could use this configuration:
hostname test ! service timestamps debug uptime service timestamps log uptime ! event manager applet ReloadNotify event timer countdown name Delay time 20 action 1.0 info type routername action 1.1 mail server "mail.example.com" → to "ops@example.com" from "$_info_routername@example.com" → subject "Router reload: $_info_routername" action 1.2 syslog msg "E-mail was sent"
Ref: Send e-mail after a router reload
How To Send MIME Attachments Using EEM
::cisco::eem::register_event_none
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
# First, create the headers and body of your message
set email_body_pre "Mailservername: $_email_server
From: $_email_from
To: $_email_to
Cc:
Subject: Email from Router $_router_name
MIME-Version: 1.0
Content-type: multipart/mixed; boundary=\"EEM_email_boundary\"
\n--EEM_email_boundary\n
\n--EEM_email_boundary
Content-Type: application/octet-stream
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=\"test.log\"\n\n"
# Then, read in the data you wish to attach.
if [catch {open "flash:test.log"} result] {
error $result $errorInfo
}
set fd $result
# Encode that data using the built-in base64 library.
set email_b64 [::base64::encode [read $fd]]
close $fd
# Construct the final message with the headers, body, and MIME parts.
set email_body_mime "\n--EEM_email_boundary--"
set email_body [format "%s%s%s" $email_body_pre $email_b64 $email_body_mime]
# Send the email.
if [catch {smtp_send_email $email_body} result] {
error $result $errorInfo
}
Ref:How To Send MIME Attachments Using EEM
No comments:
Post a Comment