#!/bin/tcsh -x
#
# File Name:    send_mail
# File Purpose: This file is Genesis hook written in c-shell.
#		It is that called by statistic collection package 
#               to provide a statistic information to Frontline
# Written by:   Michael Litvin (Frontline PCB Solutions LP)
#
if ( a$1 == "a" ) then
	echo "Send Mail Genesis Hook - Send Statistic report to Frontline"
	echo "Usage : send_mail statistic_delta_file"
	exit
endif
if ( ! -f $1 ) then
	echo send_mail:File $1 not found
	exit
endif 

###
### Configuration of the mail
###
set MailSubject     = "Statistic Report"                 ### Please don't change
set MailToStatistic = "statistic@frontline-pcb.com"      ### Please don't change

###
### Site dependent configuration ( for NT platform )
###
set MailFrom   = StatisticReporter@frontline-pcb.com     ### Please put your correct mail address
							 ### instead.                  
set MailServer = mailgw.frontline-pcb.com  		 ### Please put correct name of your local
							 ### SMTP mail server instead.

if ( `uname` == "WINDOWS_NT" ) then
###
### Send mail from Windows platform ###
###
### Sending the mail by using "blat" utility
###
	set SendMailUtility = ${GENESIS_EDIR}/misc/blat.exe
	if ( ! -e $SendMailUtility ) then
		echo "send_mail:Send mail utility $SendMailUtility not exist or invalid"
		exit 1
	endif
	$SendMailUtility $1 -t "$MailToStatistic" -s "$MailSubject" -f "$MailFrom" -server "$MailServer"
###
### If you want to receive a copy of the mail please add here an additional sending line 
###
else
###
### Send mail from UNIX
###
### Sending the mail by using standard mailx utility.
### If this utility is not available in your environment ( local net ) please put 
### another command instead 
###
	set SendMailUtility = mailx
	which $SendMailUtility >> /dev/null
	if ( $status ) then
		echo "send_mail:Send mail utility $SendMailUtility not exist or invalid"
		exit 1
	endif
	$SendMailUtility -s "$MailSubject" $MailToStatistic < $1
###
### If you want to receive a copy of the mail please add here an additional sending line 
###
endif
### 