ROS 6.X 自动备份系统发邮箱。

老规矩直接上脚本。

[php]
#备份文件名称为当前日期设置
:local date [/system clock get date]
:local day [:pick $date 4 6]
:local month [:pick $date 0 3]
:local year [:pick $date 7 11]
:local convert ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $date 0 3]]+1);
:if ($convert <=9) do={
:set convert ("0".$convert)}
:set date ("MikroTik-".$year.$convert.$day);
/system backup save name=$date;
#SMTP服务器设置
:local smtps "smtp.qq.com"
#邮件端口设置
:local ports "25"
#寄件人设置
:local Mailings "1432868020@qq.com"
#寄件人密码设置
:local pass "11111111"
#TSL加密设置
:local tlss "填yes或no"
#收件人设置
:local Collection "1432868020@qq.com"
#发送内容设置
:local Contents "邮件发送时的公网IP是:"
#发送主题设置
:local Themes "MikroTik系统备份"
#接口名称设置
:local ddnsinterface "pppoe-out1"
#服务器名称设置
:local ServerName "附件为您RouterOS最新的系统配置备份文件"
:local smtpp [:resolve $smtps]
:local szccc "www.rosm.cn提供支持"
:local xueyingsz "技术问题请联系我"
:local Belief "RouterOS技术支持QQ:1432868020"
/tool e-mail set start-tls=$tlss address=$smtpp port=$ports from=$Mailings user=$Mailings password=$pass
:global ddnssystems ("您的路由器版本是为 MikroTik v" . [/system package get system version] )
:local ipssfn [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:global ipss [:pick $ipssfn 0 [:find $ipssfn "/" ] ]
/tool e-mail send start-tls=$tlss to=$Collection subject=$Themes body=("$ServerName\n$ddnssystems\n$Contents$ipss\n\n$xueyingsz\n$Belief\n$szccc") file=$date
:log warning "系统数据已备份,邮件已发送(www.rosm.cn)"
:log warning ("外网IP =" ."$ipss")
#20150613Ali提供
[/php]

更新记录:
2017/04/04 删除错误参数from=$Collection
2017/04/05 添加TSL加密选项

发表回复