#!/bin/bash
day=`date +%Y%m%d_%H%M`
log_dir=/usr/local/share/zabbix/alertscripts/log
name=`echo $1 |awk -F@ '{print $1}'`
function redirect_log ()
{
    log_file=$log_dir/mail_${day}_$name.log
    log_err=$log_dir/mail_${day}_$name.err.log
    mkdir -p $log_dir
    exec 1>$log_file
    exec 2>$log_err
}    # ----------  end of function redirect_log  ----------
redirect_log
echo "$3" | mailx -s "$2" $1
[ $? -eq 0 ] && echo  "mailto:$1 sub:$2 content:$3 Successfull." || echo "mailto:$1 sub:$2 content:$3 Failed."