ارسال ایمیل هشدار از RouterOS
RouterOS یک کلاینت ایمیل داخلی دارد که میتواند از طریق هر سرور SMTP پیام ارسال کند. با ترکیب آن با اسکریپتها و Netwatch، میتوانید هشدارهای خودکار برای رویدادهای شبکه تنظیم کنید.
پیکربندی کلاینت ایمیل
TEXT
/tool e-mail set server=smtp.gmail.com port=587 start-tls=yes from=router@example.com user=router@example.com password=your-app-passwordمشاهده تنظیمات فعلی
TEXT
/tool e-mail printاستفاده از Gmail
Gmail به App Password نیاز دارد (نه رمز عبور اصلی):
- به تنظیمات گوگل بروید → Security → App Passwords
- یک App Password برای "Mail" بسازید
- آن رمز ۱۶ کاراکتری را در RouterOS استفاده کنید
TEXT
/tool e-mail set server=smtp.gmail.com port=587 start-tls=yes from=youraddress@gmail.com user=youraddress@gmail.com password=abcd1234efgh5678ارسال ایمیل آزمایشی
TEXT
/tool e-mail send to="admin@example.com" subject="Test" body="This is a test."برای بررسی خطاها:
TEXT
/log print where topics~"e-mail"هشدار CPU بالا
TEXT
/system script add name=cpu-alert source={
:local cpu [/system resource get cpu-load]
:if ($cpu > 80) do={
/tool e-mail send to="admin@example.com" subject="High CPU" body=("CPU: " . $cpu . "%")
}
}
/system scheduler add name=cpu-check interval=5m on-event="/system script run cpu-alert"ایمیل از Netwatch
TEXT
/tool netwatch add host=8.8.8.8 interval=30s timeout=2s down-script="/tool e-mail send to="admin@example.com" subject="WAN DOWN" body="WAN unreachable!"" up-script="/tool e-mail send to="admin@example.com" subject="WAN UP" body="WAN restored.""گزارش وضعیت روزانه
TEXT
/system script add name=status-email source={
:local cpu [/system resource get cpu-load]
:local uptime [/system resource get uptime]
:local body ("CPU: " . $cpu . "% | Uptime: " . $uptime)
/tool e-mail send to="admin@example.com" subject="Daily Status" body=$body
}
/system scheduler add name=daily-status interval=1d start-time=07:00:00 on-event="/system script run status-email"عیبیابی
- لاگ را بررسی کنید:
/log print where topics~"e-mail" - مطمئن شوید DNS کار میکند:
:put [:resolve smtp.gmail.com] - بررسی کنید پورت ۵۸۷ در فایروال مسدود نیست
خلاصه
- تنظیمات SMTP زیر
/tool e-mail setقرار میگیرند - با
/tool e-mail sendایمیل ارسال کنید - برای Gmail از App Password استفاده کنید
- با اسکریپتها و Netwatch هشدارهای خودکار بسازید
