E-mail notification postoperation trigger script

This postoperation trigger action fires when a developer finishes delivering work to the integration stream. The script composes and sends an e-mail message to other developers on the project team telling them that a deliver operation has just finished. The script uses HCL VersionVault environment variables to provide the following details about the deliver operation in the body of the message:
  • Project name
  • Development stream that delivered work
  • Integration stream that received delivered work
  • Integration activity created by the deliver operation
  • Activities delivered
  • Integration view used by deliver operation
# Perl script to send mail on deliver complete.

##################################################################
# Simple package to override the "open" method of Mail::Send so we
# can control the mailing mechanism.
package SendMail;

use Config;
use Mail::Send;

@ISA = qw(Mail::Send);

sub open {
   my $me = shift;
   my $how;  # How to send mail
   my $notused;
   my $mailhost;

   # On Windows use SMTP

   if ($Config{'osname'} eq 'MSWin32') {
   $how = 'smtp';
   $mailhost = "localmail0.company.com";
   }

   # else use defaults supplied by Mail::Mailer

   Mail::Mailer->new($how, $notused, $mailhost)->open($me);
}

#
##################################################################
# Main program

   my @to = "developers\@company.com";
   my $subject = "Delivery complete";

   my $body = join '', ("\n",
      "UCM Project: ", $ENV{CLEARCASE_PROJECT}, "\n",
      "UCM source stream: ", $ENV{CLEARCASE_SRC_STREAM}, "\n",
      "UCM destination stream: ", $ENV{CLEARCASE_STREAM}, "\n",
      "UCM integration activity: ", $ENV{CLEARCASE_ACTIVITY}, "\n",
      "UCM activities delivered: ", $ENV{CLEARCASE_DLVR_ACTS}, "\n",
      "UCM view: ", $ENV{CLEARCASE_VIEW_TAG}, "\n"
   );

   my $msg = new SendMail(Subject=>$subject);

   $msg->to(@to);
   my $fh  = $msg->open($me);
   $fh->print($body);
   $fh->close();
   1; # return success
#
##################################################################