Alert using email

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Alert using email

  • Creator
    Topic
  • #49519
    Rick Pritchett
    Participant

    I was wondering if anyone had a sample script that they use for email notifications.  We are on a Windows 2003 server running Cloverleaf 5.5.

Viewing 11 reply threads
  • Author
    Replies
    • #62294
      Charlie Bursell
      Participant

      There are many Windows based command line mailer available, bmail comes to mind.  SImply Google for them.  Then you cal exec from a Tcl script.

      We also use a package that I modified called tclMail.

    • #62295
      Rick Martin
      Participant

      We also have a TCL proc which uses the mime and smtp TCL packages (which you would have to download and install); this assumes you have SMTP access to your mail server.

      Code:

      ######################################################################
      # send_simple_email – sends email using smtp/mime packages
      # Args: recipients comma-separated email addresses
      #       subject   message subject
      # body       message body
      # Returns:  nothing
      #
      proc send_simple_email {recipients subject body} {

         package require mime
         package require smtp

         set token [mime::initialize -canonical text/plain -string $body]
         mime::setheader $token Subject $subject
         smtp::sendmessage $token -header [list From “FromName “] -header “To $recipients” -servers “mail.domain.com”
         mime::finalize $token

         return 0
      }

    • #62296
      Rick Pritchett
      Participant

      where can i find those

    • #62297
      Gary Atkinson
      Participant

      Check in your $HCIROOT/tcl/lib/tcllib1.8 directory.  If you don’t have them sourceforge.net is good “source” for open source code.

    • #62298
      Rick Pritchett
      Participant

      ok i have the packages but how do i use this script

    • #62299
      Gary Atkinson
      Participant

      I have used shell scripts with alerts, but I think using Tcl is same process.  You can call your Tcl file and any arguments in the action section.

    • #62300
      Rick Pritchett
      Participant

      oh i am calling the proc using the following line.

    • #62301
      Rick Martin
      Participant

      Try removing the braces around your arguments:

      sendEmailMessage cloverleaf@here.com rlp71@some.com xx.xx.x.xx subject body

      You may have to put quotes or braces around any argument that contain white space like your subject or body.

    • #62302
      Gary Atkinson
      Participant

      In your .tcl file call $argv.

      ie. proc sendmail {address text} {

      puts “address is $address”

      puts “text is $text”

      }

      set address [lindex $argv 0]

      set text [lindex $argv 1]

      sendmail $address $text

      Then from the shell tclsh arg arg

    • #62303
      Rick Pritchett
      Participant

      is sendmail a tcl command that comes with cloverleaf?

      any ideas why it will not work

      called it from the alert as tcl

      call:

      sendmail XXXXX@XXXXX.com “Thread Down”

      proc:

      proc sendmail {address text} {

      puts “address is $address”

      puts “text is $text”

      }

      {

      set address [lindex $argv 0]

      set text [lindex $argv 1]

      sendmail $address $text

      return

      {

    • #62304
      Gary Atkinson
      Participant

      That was just an example proc I used with using argv.  So, you run your tcl file like this from the cmd line.

      Code:

      H:>tclsh C:TEMPsendmail.tcl gary “Hi there”
      address is gary
      text is Hi there

      Under action section when building an alert, use the alert action of “exec”.  

      Two more things I forgot  ðŸ’¡  make sure you have the path to tclsh in the top line of your script using #!. Also, make the file is executable.  

      Hope this helps  ðŸ˜‰

    • #62305

      Charlie Bursell wrote:

      We also use a package that I modified called tclMail.

      Code:

      package require tclMail
      puts “Hello, World!”

      Code:

      Error: can’t find package tclMail
         while executing
      “package require tclMail”
         (file “tclmail.tcl” line 1)

      Where can I get the tclMail package?

      -- Max Drown (Infor)

Viewing 11 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,116
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10