TCL script sending authenticated mail

Version 1
    This document was generated from CDN thread

    Created by: Jan Pecsok on 21-03-2013 08:03:56 AM
    Hi, I dont know if this is the right section, but I need help with TCL script that would send  email when some kind of syslog event
    happen. The easy way is use EEM applet, but I cant use that. The problem is, that I use authenticated SMTP server to send the mail.
    And additionaly, password ends by @. So I cant use the default practice.
    What I consider default practice is following:
    defining variables:
    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
    using action:
    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"
    But this doesnt work. So I need another way how to send email. My tip is following script

    ::cisco::eem::register_event_none

    package require smtp
    package require mime
    package require SASL
     
    proc send_simple_message {recipient email_server subject body user password} {
        
       
        set token [mime::initialize -canonical text/plain  -string $body]
        mime::setheader $token Subject $subject
        smtp::sendmessage $token -recipients $recipient -servers $email_server  -username $user -password $password
        mime::finalize $token
    }

    send_simple_message someone@somewhere.com localhost "This is the subject." "This is the message." admin cisco
     
    But I dont know, if it can work, because its genar TCL script and it needs packages like smtp and such, so I would like to know
    if there is some easy way to send email by TCL script, using authenticated SMTP server. I hope its understandable I have very
    little experience with TCL, so I really dont know, any help appreciated.
    Hi John.
     

    Subject: RE: TCL script sending authenticated mail
    Replied by: Yaw-Ming Chen on 21-03-2013 12:44:03 PM
    We discuss voice related Tcl API in this forum. Suggest you to post question in Cisco Beyond:
    https://supportforums.cisco.com/community/netpro/network-infrastructure/eem?view=discussions
     
    Thanks !