cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

7356
Views
19
Helpful
34
Replies
Highlighted
Beginner

eem on cisco 877, trouble with mail server action and smtp auth

hello all,

i'm using a router 877 at home and i really need to check out what this router do during the day.

So some time ago i configured it using some eem actions and sending to me email, without any problems.

Yesterday I changed my internet provider and now i need to use smtp autheticantion to send emails.

I read about how to authenticate, like username:password@host and also made a fast search here, without solve my problem.

I need to put as username the email of the provider like: mouse@host.com:mypassword@smtpserveraddress.com.

So, i want to know if someone had the same problem and solved it. Of course i couldn't use @ two times or eem would think that host.com is my smtp server! And right now is going in this way!

My IOS version is 15.1(2)T2, eem version is 3.1.

Hope someone could help me!

Thank you in advance.


Sandro

Everyone's tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

Here you go.

::cisco::eem::event_register_syslog occurs 1 pattern ".*LINEPROTO-5-UPDOWN.*FastEthernet3.*"

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*


set mail_pre "Mailservername: myusername@providerDomain:mypassword@providerSMTP\n"
append mail_pre "From: myusername@providerdomain\n"
append mail_pre "To: myusername2@providerDomain2\n"
append mail_pre
append mail_pre "Subject: Check VOIP ATA\n\n"
append mail_pre "Please check VOIP ATA, something not working properly\n\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
if [catch {smtp_send_email $mail_msg} result] {
    error $result $errorInfo
}

Save this to a file that ends with ".tcl" (e.g. interface-down-fritz.tcl), then copy it to your EEM policy directory on your router (i.e. the one specified in "event manager directory user policy").  Then register the policy with the command "event manager policy interface-down-fritz.tcl".

View solution in original post

34 REPLIES 34
Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

This is a known limitationwith SMTP AUTH and EEM.  An enhancement request, CSCsv24106, was filed to allow for escaping the '@' in a username.  However, I've looked over the code in 15.1(2)T, and it appears that the username with the '@' will be properly understood, provided you're using Tcl.  If you use applets, then it will not work.  If you post your applet, I can convert it to a Tcl policy for you.

Beginner

Re: eem on cisco 877, trouble with mail server action and smtp a

Thank you Joseph for your reply.

Here it's a sample, i have other that look like this.

If you can give back an example i will learn tcl also

Thank you in advance!

Sandro

event manager applet interface-down-fritz
event syslog occurs 1 pattern ".*LINEPROTO-5-UPDOWN.*FastEthernet3.*"
action 1.0 mail server "myusername@providerDomain:mypassword@providerSMTP" to "myusername2@providerDomain2" from "myusername@providerdomain" subject "Check VOIP ATA" body "Please check VOIP ATA, something not working properly"

Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

Here you go.

::cisco::eem::event_register_syslog occurs 1 pattern ".*LINEPROTO-5-UPDOWN.*FastEthernet3.*"

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*


set mail_pre "Mailservername: myusername@providerDomain:mypassword@providerSMTP\n"
append mail_pre "From: myusername@providerdomain\n"
append mail_pre "To: myusername2@providerDomain2\n"
append mail_pre
append mail_pre "Subject: Check VOIP ATA\n\n"
append mail_pre "Please check VOIP ATA, something not working properly\n\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
if [catch {smtp_send_email $mail_msg} result] {
    error $result $errorInfo
}

Save this to a file that ends with ".tcl" (e.g. interface-down-fritz.tcl), then copy it to your EEM policy directory on your router (i.e. the one specified in "event manager directory user policy").  Then register the policy with the command "event manager policy interface-down-fritz.tcl".

View solution in original post

Beginner

Re: eem on cisco 877, trouble with mail server action and smtp a

Thank you again! Hope you could help me with this one too, i understand now how to look for UPDOWN of ports, but not how to for a cronjob like this:

event manager applet sendmyip
event timer cron cron-entry "*/30 * * * *"

Is there or on cisco a reference for the first line command (i mean the check that will start the policy)?

I don't want to ask more, i prefer to learn

Anyway i will test it soon, i have to fix this quickly!

Sandro

Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

Beginner

Re: eem on cisco 877, trouble with mail server action and smtp a

Hello again,

i got this in my tests:

09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: wrong 4th line format.
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: usage: Cc:
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     while executing
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: "smtp_send_email $mail_msg"
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     invoked from within
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: "$slave eval $Contents"
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     (procedure "eval_script" line 7)
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     invoked from within
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: "eval_script slave $scriptname"
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     invoked from within
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: "if {$security_level == 1} {       #untrusted script
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:      interp create -safe slave
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:      interp share {} stdin slave
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:      interp share {} stdout slave
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: ..."
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: Tcl policy execute failed:
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: wrong 4th line format.
09:10:34: %HA_EM-6-LOG: send-my-ip.tcl: usage: Cc:

I left the fourth line blank as you gave me. Maybe i have to put a Cc: without address? I looked in the other link for tcl eem and i think that declare the line it's mandatory.

Is that true?

Thank you!

Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

Yes, the conversion left out the mandatory Cc: field.  Change the empty append line to:

append mail_pre "Cc: \n"

Then that should work.

Beginner

Re: eem on cisco 877, trouble with mail server action and smtp a

Hello again Joseph,

thank you again. Now it works correctly. I didn't try without any cc address, i putted the same as the sender for a test.

But do you use a program to convert an applet to a tcl?

Bye!

Sandro

Hall of Fame Cisco Employee

Re: eem on cisco 877, trouble with mail server action and smtp a

Yes, we have a web-based tool internally we can use.  I typically do it for simple applets as it saves me time typing :-).

Beginner

Re: eem on cisco 877, trouble with mail server action and smtp a

Cool, i hope that a time cisco will share this with us too!

Bye!

Beginner

eem on cisco 877, trouble with mail server action and smtp auth

Hi Joseph,

We aim to send email to our mail server once access-list changed, so I followed eveything as your instructed to send email from the router to our mail server.I have created a test directory and save scrip with.tcl then push it to router. We are getting the following error. could you look into my script and show us the correct way.

many thanks.

3845-Dial-A#sh event manager directory user policy

flash:/Test/access-list-changed.tcl

3845-Dial-A(config)#event manager policy flash:/Test/access-list-changed

Embedded Event Manager configuration: flash:/Test/access-list-changed does not have valid policy extension

3845-Dial-A(config)#event manager policy flash:/Test/access-list-changed.tcl

Register event failed:couldn't read policy file: permission denied

Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy

flash:/Test/access-list-changed.tcl: Unknown error 0

::cisco::eem::event_register_syslog occurs 1 pattern "ip access-list extended"

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

set mail_pre "10.1.1.1:me@bank.com:M123@bank.com" SMTP\n"

append mail_pre "From: me@bank.com\n"

append mail_pre "To:admin@bank.com\n"

append mail_pre

append mail_pre "The ACL on this router have changed\n\n"

set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]

if [catch {smtp_send_email $mail_msg} result] {

    error $result $errorInfo

}

Hall of Fame Cisco Employee

eem on cisco 877, trouble with mail server action and smtp auth

You need to configure:

event manager directory user policy flash:/Test

event manager policy access-list-changed.tcl

Frequent Contributor

eem on cisco 877, trouble with mail server action and smtp auth

Hello Joseph,

I read your excellent guide and I thank you for your efforts!

I am not sure about couple of things though:

- @providerSMTP is it an IP address or a FQDN

Here is the current config:

event manager directory user policy "flash:/tcl"


event manager applet Email

event timer watchdog time 28800

action 1 syslog priority notifications msg "Manual backup completed"

action 2 policy Email.tcl


event manager policy Email.tcl

dir flash:tcl

Directory of flash:/tcl/

    11  -rw-         665  Nov 22 2012 17:40:36 +02:00  Email.tcl

Is there anything else I forgot?

Many thanks!

Hall of Fame Cisco Employee

eem on cisco 877, trouble with mail server action and smtp auth

It is best if the SMTP server is an IP address.  However, in newer versions of IOS, both an IP and an FQDN will work (provided the device is configured with a DNS server).

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards