1.下载安装sendEmail(下载绿色版,解压可直接使用)
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar -xzvf sendEmail-v1.56.tar.gz
mv sendEmail-v1.56 /usr/local/sendemail
ln -s /usr/local/sendemail/sendEmail /usr/sbin/sendmail
2.发送邮件
sendmail -f [email protected] -t @qq.com -s smtp..com -u "邮件主题" -o message-content-type=html -o message-charset=utf8 -xu xpeka -xp xxxx -m "邮件内容"
命令说明:
sendmail:邮件主程序
-f [email protected]:发件人邮箱
-t [email protected]:收件人邮箱
-s smtp.163.com:发件人的smtp服务器地址
-u "邮件主题":邮件的标题
-o message-content-type=html:邮件内容的格式,html表示它是html格式
-o message-charset=utf8:邮件内容编码
-xu x.peka:发件人的邮箱账号
-xp xxxx:发件人邮箱密码
-m "邮件内容":邮件的具体内容
发送成功之后会有如下提示:
[root@localhost myshell]# sendmail -f [email protected] -t [email protected] -s smtp..com -u lwj -o message-content-type=html -o message-charset=utf8 -xu xpeka -xp xxxx -m lzy Feb 02 17:17:30 localhost sendmail[6652]: Email was sent successfully!
#!/bin/sh
to=$
subject=$
body=$
sendemail -f [email protected] -t "$to" -s smtp..com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu x.peka -xp l123456 -m "$body" >>/tmp/sendemail.log