cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2241
Views
0
Helpful
5
Replies

EEM tcl policy error while sending mail

SAMEHELSAMMAK
Level 1
Level 1

dear all

i am trying to create an eem script or tcl file to be executer when i log in or when the vdsl controller goes down

 

i am sending mail using the smtp server : smtp.office365.com

when sending emails the port must be 586 with tls security and must use authentication with the sender email and password

 

i tried to approaches

 

first command line approach:

 

event manager applet WEBSERVER_login
event syslog pattern "%WEBSERVER-5-LOGIN_PASSED: R0/0: : Login Successful from host 192.168.1.10"
action 1.0 mail server smtp.office365.com from user@mydomain.COM to user@mydomain.COM subject "Login Successful from host 192.168.1.10 by user" body "$_syslog_msg" port 587 secure TLS
action 1.1 syslog msg "%WEBSERVER-5-LOGIN_PASSED: R0/0: : Login Successful from host 192.168.1.10 - Mail Sent"
exit

 

but i get error : DEBUG(smtp_lib) : fh_smtp_read {530 5.7.57 Client not authenticated to send mail. [MRXP264CA0039.FRAP264.PROD.OUTLOOK.COM]

------------------------------------

so i tried the second approach a tcl script

::cisco::eem::event_register_syslog pattern {%WEBSERVER-5-LOGIN_PASSED: R0/0: : Login Successful from host 192.168.1.10}

#
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
#
#

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

array set arr_einfo [event_reqinfo]


set mail_pre "Mailservername: user@mydomain.COM:password@smtp.office365.com\n"
append mail_pre "From: user@mydomain.COM\n"
append mail_pre "To: user@mydomain.COM\n"
append mail_pre "Cc: \n"
append mail_pre "Subject: Login Successful from host 192.168.1.10\n\n"
append mail_pre "Login Successful from host 192.168.1.10\n\n"
append mail_pre "Port: 587\n"
append mail_pre "secure TLS\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
if [catch {smtp_send_email $mail_msg} result] {
error $result $errorInfo
}

action_syslog msg "%WEBSERVER-5-LOGIN_PASSED: R0/0: : Login Successful from host 192.168.1.10 - Mail Sent"

 

but i get this error

Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: error connecting to mail server:
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: cannot connect to all the candidate mail servers
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: while executing
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: "smtp_send_email $mail_msg"
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: "$slave eval $Contents"
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: (procedure "eval_script" line 7)
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: "eval_script slave $scriptname"
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: invoked from within
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: "if {$security_level == 1} { #untrusted script
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: interp create -safe slave
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: interp share {} stdin slave
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: interp share {} stdout slave
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: ..."
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50)
Mar 24 20:35:07.683: %HA_EM-6-LOG: sendmail.tcl: Tcl policy execute failed:
Mar 24 20:35:07.684: %HA_EM-6-LOG: sendmail.tcl: error connecting to mail server:
Mar 24 20:35:07.684: %HA_EM-6-LOG: sendmail.tcl: cannot connect to all the candidate mail servers

--------------------------------

 

what can i do to make it work ?

 

1 Accepted Solution

Accepted Solutions

SAMEHELSAMMAK
Level 1
Level 1

I MANGED TO GET IT WORKING BY USING MAILJET.COM SERVER

 

 

 

View solution in original post

5 Replies 5

balaji.bandi
Hall of Fame
Hall of Fame
but i get error : DEBUG(smtp_lib) : fh_smtp_read {530 5.7.57 Client not authenticated to send mail.

First, i would look above error - and ask if this device has reachability to the internet to connect to your email Server ?

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

yes internet working , and when i telnet to server on port 587 it connects , and also i can ping server with no problems

 

ping smtp.office365.com
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 52.98.163.50, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 51/53/56 ms

once you able to telnet to that port are you able to use your credential and test it ?

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

yes i can

but i must use the complete email : user@mydomain.com 

 

that is why i tried to use the tcl file to do that

 

set mail_pre "Mailservername: user@mydomain.COM:password@smtp.office365.com\n"

SAMEHELSAMMAK
Level 1
Level 1

I MANGED TO GET IT WORKING BY USING MAILJET.COM SERVER

 

 

 

Review Cisco Networking for a $25 gift card