Sent mail -Shell:Mark 一下。






shell发送邮件(smtp)

#!/bin/sh
# shell_mailer.sh, Shell Mailer, (MTA)
# #---------------------
# # Variables
# #---------------------

sender=$1 # 发信人的email
reciver=$2 # 收信人的email
subject=$3 # 邮件的标题
email_content_txt=$4 # 存放邮件内容的文件
smtp='mail.163.com' # 修改这里,邮件服务器地址

if [ "$#" != 4 ]; then
   echo "Usage: $0 mailsender@doamin.commailrecieve@domain.comsubject text_file"
   exit 2
fi
# text_file的内容为邮件正文

mesge(){
cat << EOF
From: <$sender>
To: <$reciver>
Subject: $subject
Date: `date` +0800
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-Mailer: Solaris Mail Client
X-MimeOLE: Powered by Solaris

# # 邮件使用了ASCII编码,而非BASE64,这可以保证存储邮件正文的文件中直接使用常见的ASCII明文进行编辑
#
EOF
test -r $email_content_txt && cat $email_content_txt
}
#
send_mail(){
(
sleep 5
for comm in "helo 163.com" "mail from:<$sender>" "rcpt to:<$reciver>" "data"
do
     echo "$comm"
     sleep 3
done
#mesge
sleep 3
echo ".")| telnet $smtp 25
}

send_mail







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值