2013年2月18日 星期一

SMTP 使用NC範例

#!/bin/bash

/root/mail_raid_message.sh | nc smtp.server 25 2>&1 >/dev/null

mail_raid_message.sh 內容如下
#!/bin/bash
HELO=smtp.server
FROM=""
TO=""
DATE=$(date '+%a, %d %b %Y %H:%M:%S %z')

echo $DATE
echo "HELO $HELO"
echo "MAIL FROM:$FROM"
echo "RCPT TO:$TO"
echo "DATA"
sleep 1

echo "From:$FROM"
echo "To:$TO"
echo "Date:$DATE"
echo "Subject:$DATE "
echo "mail message"

echo "."

sleep 1

echo "QUIT"

沒有留言: