#!/bin/bash
smail(){
smtp="mail.mailadd.com 25"
smtp_domain="mailadd.com"
FROM="xxx@mailadd.com"
RCPTTO=$1
username_base64="xxxxxxxxxxxxxxxxx"
password_base64="xxxxxxxx"
local_ip=`ifconfig|grep Bcast|awk -F: '{print $2}'|awk -F " " '{print $1}'|head -1`
local_name=`uname -n`
( for i in "ehlo $smtp_domain" "AUTH LOGIN" "$username_base64" "$password_base64" "MAIL FROM:<$FROM>" "RCPT TO:<$RCPTTO>" "DATA";do
echo $i
sleep 4
done
echo "Subject:server alert"
echo "From:<$FROM>"
echo "To:<$RCPTTO>"
echo ""
echo "server $local_name up, ip:$local_ip"
echo "."
sleep 2
echo "quit" )|telnet $smtp
}
smail xxx@163.com