03-24-2021 03:07 PM
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 ?
Solved! Go to Solution.
09-23-2021 03:34 AM
03-24-2021 03:21 PM
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 ?
03-24-2021 03:28 PM
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
03-24-2021 04:03 PM
once you able to telnet to that port are you able to use your credential and test it ?
03-24-2021 04:06 PM
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"
09-23-2021 03:34 AM
I MANGED TO GET IT WORKING BY USING MAILJET.COM SERVER
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