11-25-2015 04:08 AM
Hello,
I'm having trouble to get the library smtp_send_email working.
I have a tcl script which I register with eem. I set all the env vars like _email_server, _email_to etc.
But when the script is executed i get the following message:
002716: Nov 25 2015 12:54:22.764 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_connect : attempt 1
002717: Nov 25 2015 12:54:23.023 CET: [fh_smtp_debug_cmd]
002718: Nov 25 2015 12:54:23.023 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_read : 220 <mailservername> -- Server ESMTP (PMDF V6.6#32005)
002719: Nov 25 2015 12:54:23.023 CET: [fh_smtp_debug_cmd]
002720: Nov 25 2015 12:54:23.023 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_write : HELO es334A2.mydomain.de
002721: Nov 25 2015 12:54:23.089 CET: [fh_smtp_debug_cmd]
002722: Nov 25 2015 12:54:23.089 CET:
es334A2#%HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_read : 250 <mailservername> OK, [172.19.17.196].
002723: Nov 25 2015 12:54:23.089 CET: [fh_smtp_debug_cmd]
002724: Nov 25 2015 12:54:23.089 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_write : MAIL FROM:<es334A2@mydomain.com>
002725: Nov 25 2015 12:54:23.170 CET: [fh_smtp_debug_cmd]
002726: Nov 25 2015 12:54:23.170 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_read : 250 2.5.0 Address Ok.
002727: Nov 25 2015 12:54:23.170 CET: [fh_smtp_debug_cmd]
002728: Nov 25 2015 12:54:23.170 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_write : RCPT TO:<me@mydomain.com>
002729: Nov 25 2015 12:54:23.250 CET: [fh_smtp_debug_cmd]
002730: Nov 25 2015 12:54:23.250 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_read : 250 2.1.5 me@mydomain.com OK.
002731: Nov 25 2015 12:54:23.250 CET: [fh_smtp_debug_cmd]
002732: Nov 25 2015 12:54:23.250 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_write : DATA
002733: Nov 25 2015 12:54:23.317 CET: [fh_smtp_debug_cmd]
002734: Nov 25 2015 12:54:23.317 CET: %HA_EM-6-LOG: vlanmap.tcl : DEBUG(smtp_lib) : smtp_read : 354 Enter mail, end with a single ".".
002735: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: list element in quotes followed by "." instead of space
002736: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: while executing
002737: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: "smtp_send_email $mail_msg"
002738: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: invoked from within
002739: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: "$slave eval $Contents"
002740: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: (procedure "eval_script" line 7)
002741: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: invoked from within
002742: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: "eval_script slave $scriptname"
002743: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: invoked from within
002744: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: "if {$security_level == 1} { #untrusted script
002745: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: interp create -safe slave
002746: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: interp share {} stdin slave
002747: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: interp share {} stdout slave
002748: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: ..."
002749: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50)
002750: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: Tcl policy execute failed:
002751: Nov 25 2015 12:54:23.320 CET: %HA_EM-6-LOG: vlanmap.tcl: list element in quotes followed by "." instead of space
myswitch#
The Hardware is 2960X with IOS 15.2(4)E.
The event manager version is:
Embedded Event Manager Version 4.00
Component Versions:
eem: (rel9)1.2.6
eem-gold: (rel1)1.0.2
eem-call-home: (rel2)1.0.4
Event Detectors:
Name Version Node Type
application 01.00 node0/0 RP
identity 01.00 node0/0 RP
mat 01.00 node0/0 RP
neighbor-discovery 01.00 node0/0 RP
generic 01.00 node0/0 RP
routing 03.00 node0/0 RP
syslog 01.00 node0/0 RP
cli 01.00 node0/0 RP
config 01.00 node0/0 RP
counter 01.00 node0/0 RP
crash 01.00 node0/0 RP
ds 01.00 node0/0 RP
env 01.00 node0/0 RP
gold 01.00 node0/0 RP
interface 01.00 node0/0 RP
ioswdsysmon 01.00 node0/0 RP
nf 01.00 node0/0 RP
none 01.00 node0/0 RP
oir 01.00 node0/0 RP
snmp 01.00 node0/0 RP
snmp-object 01.00 node0/0 RP
snmp-notification 01.00 node0/0 RP
test 01.00 node0/0 RP
timer 01.00 node0/0 RP
I don't understand the message: "list element in quotes followed by "." instead of space"
This is the code I use:
#smtp_send_email
if {$withmail == 1 } {
set mail_pre "Mailservername: <mailservername>\n"
append mail_pre "From: es334A2@mydomain.com\n"
append mail_pre "To: me@mydomain.com\n"
append mail_pre "Cc: \n"
append mail_pre "Subject: LINK UP\n"
append mail_pre " \n"
append mail_pre "Test1\n"
append mail_pre "Test2\n\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
puts stdout "mail_msg:\n$mail_msg"
puts stdout "routername: $routername"
if [catch {smtp_send_email $mail_msg} result] {
error $result $errorInfo
}
Any help is very appreciated.
Kind regards,
Andreas
Solved! Go to Solution.
01-19-2016 04:08 AM
Wrong split chars. Try this:
proc ::cisco::lib::smtp_chk_reply { sock succ_code } {
variable reply_code_str
set r [ smtp_read $sock ]
if {$r == -1} {
return -code error "Socket closed by remote server"
}
set k [lindex [split $r " "] 0]
if {$k != $succ_code} {
return -code error [concat From SMTP server: $r\n$reply_code_str($k)]
}
}
11-26-2015 10:52 AM
This code is not proper Tcl. Please attach the script instead of pasting in the code so we can get a complete picture the way it is actually being interpreted.
11-26-2015 11:13 PM
11-28-2015 03:57 PM
I don't see anything wrong with this code or the SMTP library code. I can only guess that there is something else in your actual policy that I'm not seeing. But if all you do is replace the email addresses with the proper values and re-register the policy, then it should work.
11-29-2015 04:26 AM
Hi,
yes, all I do is replace the values with real ones. But then it fails with the weird message:
"list element in quotes followed by "." instead of space". I don't understand if this is related to the "send_email-library" or the tcl syntax...
It doesn't matter what's in the mailbody. It seems that it doesn't came to step to process the mailbody...
The policy looks like this:
es334A2#sh event manager policy registered
No. Class Type Event Type Trap Time Registered Name
1 script user syslog Off Fri Nov 27 09:09:01 2015 vlanmap.tcl
1: syslog: pattern {LINEPROTO-5-UPDOWN: Line protocol on Interface (.*), changed state to up}
nice 0 queue-priority normal maxrun 300.000 scheduler rp_primary Secu none
Kind regards,
Andreas
11-29-2015 09:52 AM
While I don't have a 2960X, I tested with your script and the smtp_lib.tcl from the 15.2(4)E source code, and it works.
[smtp_connect] : attempt 1
[smtp_read ] : 220 xxx.cisco.com ESMTP FOO 1.2.3.4/5.6.7.8; Sun, 29 Nov 2015 17:47:59 GMT
[smtp_write] : HELO yyy.cisco.com
[smtp_read ] : 250 xxx.cisco.com Hello aaa.cisco.com [10.117.46.173], pleased to meet you
[smtp_write] : MAIL FROM:<jclarke@cisco.com>
[smtp_read ] : 250 2.1.0 <jclarke@cisco.com>... Sender ok
[smtp_write] : RCPT TO:<jclarke@cisco.com>
[smtp_read ] : 250 2.1.5 <jclarke@cisco.com>... Recipient ok
[smtp_write] : DATA
[smtp_read ] : 354 Enter mail, end with "." on a line by itself
[smtp_write] : Date: 29 Nov 2015 12:47:59 EST
[smtp_write] : Message-ID: <20151129124759.0@yyy.cisco.com>
[smtp_write] : From: jclarke@cisco.com
To: jclarke@cisco.com
Cc:
Subject: LINK UP
Testmessage if Link goes up
[smtp_write] : .
[smtp_read ] : 250 2.0.0 tATHlxxI002560 Message accepted for delivery
[smtp_write] : QUIT
[smtp_read ] : 221 2.0.0 xxx.cisco.com closing connection
So, I can only guess that the script you have registered with the EEM server is not what you've posted here. Make sure that when you make changes you re-register the policy or the changes will not go into effect.
This error typically occurs when one has a '#' on a line thinking it's a comment. Embedded comments must be preceded with a ';'.
11-29-2015 11:42 PM
Hello Joe,
the script I've registered ist exactly what I've posted.
But I made another trial.
I took a part of the original vlanmap.tcl(attached mail_test.tcl). And registered it(I know that I have to re-register the script each time I make changes to the script.).
I get a similar error message(log is attached).
I reloaded the machine twice.
To me it looks like that the lib or anything else in EEM/tcl is broken.
Edit:
I just testet the same script on a WS-C4500X-16 with IOS "cat4500e-universalk9.SPA.03.08.00.E.152-4.E.bin" and it gives me the same error message ?!? I Don't know what I'm doing wrong...
Kind regards,
Andreas
11-30-2015 12:37 PM
It might be time to open a case with TAC, then. There may be different code on the 2960X that I am not seeing when I pull it from the source code.
12-06-2015 10:51 PM
Ok, I'll see if I can address this to the TAC.
Curious that the same message appears on the 4500X...
Kind regards,
Andreas
12-07-2015 08:08 AM
Presumably with the TAC case you can share the actual script. There still might be something in your script that is being hidden here. I certainly connect reproduce, and I haven't seen anyone report this problem before.
12-07-2015 11:53 PM
Hi,
I opened a ticket and I provide the script I attached here.
I'm wondering that you assume that there is something hidden... the script I attached here is definitely the one on the switch.
Kind regards,
Andreas
12-13-2015 10:46 PM
Hello,
I got answer from the "TAC":
EEM scripts no longer supported by TAC, and it is only supported by support forums.
Please continue to check with Cisco Support Community.
>>https://supportforums.cisco.com/discussion/12714071/sendmail-tcl-eem-policy-not-working
Rgds,
Andreas
12-14-2015 07:36 AM
What is the SR number?
12-15-2015 12:24 AM
Hi,
SR 637393499
Rgds,
Andreas
01-18-2016 11:03 PM
Hi Joe,
any news on this?
Rgds,
Andreas
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide