Sending Email Alerts from RouterOS
RouterOS has a built-in email client that can send messages through any SMTP server. Combined with scripts and Netwatch, you can set up automatic email alerts for network events like link failures, high CPU usage, or unauthorized access attempts.
Configuring the Email Client
All email settings live under:
/tool e-mailBasic SMTP Configuration
/tool e-mail set server=smtp.gmail.com port=587 start-tls=yes from=router@example.com user=router@example.com password=your-app-passwordParameters:
server— SMTP server hostname or IPport— typically 587 (STARTTLS) or 465 (SSL) or 25 (plain)start-tls— enable STARTTLS encryption (yesrecommended)from— the sender email address shown to recipientsuser— SMTP login username (usually the email address)password— SMTP password or app password
View Current Settings
/tool e-mail printUsing Gmail as SMTP
Gmail requires an App Password (not your regular password) when two-factor authentication is enabled.
- Go to your Google Account → Security → App Passwords
- Create an app password for "Mail" on "Other device"
- Use that 16-character password in RouterOS
/tool e-mail set server=smtp.gmail.com port=587 start-tls=yes from=youraddress@gmail.com user=youraddress@gmail.com password=abcd1234efgh5678Sending a Test Email
/tool e-mail send to="admin@example.com" subject="Test from MikroTik" body="This is a test email."Wait a few seconds and check your inbox. If it does not arrive, check /log for errors:
/log print where topics~"e-mail"Triggering Alerts from Scripts
Alert When a Script Runs
/system script add name=send-alert source={
/tool e-mail send to="admin@example.com" subject="MikroTik Alert" body="An important event occurred on the router."
}High CPU Alert
Combine with the scheduler to check CPU usage periodically:
/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 Alert" body=("CPU load is: " . $cpu . "%")
}
}
/system scheduler add name=cpu-check interval=5m on-event="/system script run cpu-alert"Interface Down Alert
/system script add name=ether1-down-alert source={
/tool e-mail send to="admin@example.com" subject="Interface Down" body="ether1 has gone down on the router!"
}Use this with Netwatch or an interface monitoring script.
Triggering Email from Netwatch
/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="Primary WAN is unreachable!"" up-script="/tool e-mail send to="admin@example.com" subject="WAN UP" body="Primary WAN is back online.""Note the escaped quotes (") inside the netwatch script strings.
Including System Information in Emails
/system script add name=status-email source={
:local cpu [/system resource get cpu-load]
:local mem [/system resource get free-memory]
:local uptime [/system resource get uptime]
:local body ("CPU: " . $cpu . "% | Free Mem: " . $mem . " | Uptime: " . $uptime)
/tool e-mail send to="admin@example.com" subject="Daily Router Status" body=$body
}
/system scheduler add name=daily-status interval=1d start-time=07:00:00 on-event="/system script run status-email"This sends a daily status report every morning.
Troubleshooting Email
If emails are not sending:
- Check the log for SMTP errors:
/log print where topics~"e-mail"- Verify DNS — the router must be able to resolve smtp.gmail.com:
/ip dns cache print
:put [:resolve smtp.gmail.com]- Check firewall — outbound port 587 or 465 must not be blocked
- Try port 25 if 587 fails — some ISPs block non-standard SMTP ports outbound
- Use IP instead of hostname if DNS is the issue:
/tool e-mail set server=74.125.133.109Security Tips
- Do not store your main email password on the router — use app passwords or a dedicated account
- Consider creating a dedicated "router alerts" Gmail or similar account
- Rotate app passwords periodically
- Limit who can access
/tool e-mailsettings via user profiles
Summary
- Configure SMTP under
/tool e-mail set - Send emails with
/tool e-mail send to=... subject=... body=... - Use Gmail with App Passwords for easy setup
- Combine with scripts and Netwatch for automatic event-based alerts
- Check
/logfor SMTP errors when troubleshooting
