15 Temmuz 2013 Pazartesi

Shell Script to Send Mail via Telnet



      Sometimes you need to test send mail via telnet,but it's bored after 5-6 times.So you can a script.This script send mail via telnet.This script for solaris.If you use another operating system,you have to change .profile line;otherwise you can use direct.

Script takes two parameter.

MAIL=first parameter(mail adress)

STRING=second parameter(message body)

example;

ksh send_mail.ksh necati@natica.com.tr "Hello"

###############################send_mail.ksh########################################
#!/bin/ksh
. /export/home/oracle/.profile
MAIL=$1
STRING=$2

{
echo "helo"
sleep 1
echo "mail from:sender@doganay.com"
sleep 1
echo "rcpt to:$MAIL"
sleep 10
echo "data"
sleep 1
echo "subject:Mail Test"
sleep 1
echo "from: receiver@doganay.com"
sleep 1
echo "to: $MAIL"
sleep 2
echo data
sleep 2
echo subject:  Mail Test
echo
echo
echo "$STRING"
sleep 5
echo .
sleep 5
echo "quit"
} | telnet 10.10.67.102 25
#################################################################################
10.10.67.102=SMTP server ip
25=SMTP server port

Hiç yorum yok:

Yorum Gönder