mailyum install mailx
修改/etc/mail.rc
set from=fromUser@domain.com smtp=smtp.domain.comset smtp-auth-user=username smtp-auth-password=passwordset smtp-auth=login
说明:
from是发送的邮件地址
smtp是发生的外部smtp服务器的地址
smtp-auth-user是外部smtp服务器认证的用户名
smtp-auth-password是外部smtp服务器认证的用户密码
smtp-auth是邮件认证的方式
配置成功后,就可以使用了
例如:
set from=test@netinn.net smtp=smtp.netinn.net
set smtp-auth-user=test@netinn.net smtp-auth-password=testtest
set smtp-auth=login


vim /opt/SendNetworkstatusDaily.sh
#!/bin/bash
MailTo='test@netinn.net,test1@netinn.net'
#Title='Report of Server'
ImageHours='hours.png'
ImageDays='days.png'
ImageMonths='month.png'
DIR=/root
#date >>Title
mailcontent=
DIR/mailcontent
> "mailcontent"
echo -e "Hi,admin!\n" >>
mailcontent
echo -e "\t This is the report of `date +%Y-%m-%d`\t" >> mailcontent
uptime >>
mailcontent
echo -e "\t">>mailcontent
vnstat >>
mailcontent
echo -e "\t">>mailcontent
vnstat -h>>
mailcontent
vnstati -i venet0 --months --output /root/ImageMonths
vnstati -i venet0 --days --output /root/
ImageDays
vnstati -i venet0 --hours --output /root/ImageHours
cat
mailcontent | mail -s "Network Status Report" -a DIR/ImageMonths -a DIR/ImageDays -a DIR/ImageHours $MailTo

/etc/crond 追加
#send network mail to admin daily#
25 17 * * * bash /opt/SendNetworkstatusDaily.sh

vnstat

1 对 “Mail自动发送服务器监控”的想法;

  1. 发送html邮件:

    mailx -a ‘Content-Type: text/html’ -s “my subject” user@gmail.com < email.html # 创建头文件 $ cat mailheader To: user@gmail.com
    Subject: my subject
    Content-Type: text/html

    # 发送邮件
    $ cat mailheader email.html | sendmail -t
    两种方式均可。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code