Email Tool
Email Tool
Section titled âEmail ToolâTL;DR (Quick Start)
Section titled âTL;DR (Quick Start)âConfigure Gmail SMTP:
/tool e-mail set address=smtp.gmail.com port=587 tls=starttls \ from="router@gmail.com" user="yourname@gmail.com" password="xxxx-xxxx-xxxx-xxxx"Send a test email:
/tool e-mail send to="admin@example.com" subject="Test" body="Hello from MikroTik"Send email with attachment:
/tool e-mail send to="admin@example.com" subject="Backup" file=router-backup.backupGmail/Office365
Gmail and Office365 require App Passwords, not regular passwords. OAuth2 is not supported by RouterOS.
Overview
Section titled âOverviewâWhat this covers: Configuring SMTP email on your MikroTik router for sending notifications, alerts, and automated reports.
When to use this:
- Sending backup files via email
- Netwatch alerts when hosts go up/down
- Scheduled status reports
- Script-triggered notifications
- System event alerts
How it works:
- Configure SMTP server settings (
/tool e-mail set) - Send emails using
/tool e-mail send - Optionally integrate with scheduler, netwatch, or scripts
Key concepts:
- SMTP server: External mail server that relays your messages
- TLS/STARTTLS: Encryption for secure mail transmission
- App Password: Special password for services that donât support OAuth2
- Plain authentication: Only auth method supported by RouterOS
Prerequisites:
- SMTP server access (Gmail, Office365, or your own)
- App Password for Gmail/Office365 (regular passwords wonât work)
- Outbound access to SMTP ports (25, 465, or 587)
Part 1: Basic Configuration
Section titled âPart 1: Basic ConfigurationâConfigure SMTP Server
Section titled âConfigure SMTP Serverâ/tool e-mail set address=smtp.yourdomain.com port=587 tls=starttls \ from="MikroTik Router <router@yourdomain.com>" \ user="router@yourdomain.com" password="yourpassword"Configuration Parameters
Section titled âConfiguration Parametersâ| Parameter | Default | Description |
|---|---|---|
address | 0.0.0.0 | SMTP server address |
port | 25 | SMTP server port |
user | (empty) | Authentication username |
password | (empty) | Authentication password |
from | <> | Sender email address |
tls | no | Encryption: no/yes/starttls |
TLS Modes
Section titled âTLS Modesâ| Mode | Port | Description |
|---|---|---|
no | 25 | No encryption (not recommended) |
starttls | 587 | Upgrade to TLS after connecting |
yes | 465 | Implicit TLS from start |
Verify Configuration
Section titled âVerify Configurationâ/tool e-mail printExample output:
address: smtp.gmail.com port: 587 from: router@gmail.com user: yourname@gmail.com password: **************** tls: starttlsPart 2: Sending Emails
Section titled âPart 2: Sending EmailsâBasic Email
Section titled âBasic Emailâ/tool e-mail send to="admin@example.com" subject="Test Email" \ body="This is a test message from MikroTik"Email with Attachment
Section titled âEmail with Attachmentâ/tool e-mail send to="admin@example.com" subject="Router Backup" \ body="Daily backup attached" file=router-backup.backupMultiple Attachments
Section titled âMultiple Attachmentsâ/tool e-mail send to="admin@example.com" subject="Router Files" \ file=export.rsc,router-backup.backupEmail with CC
Section titled âEmail with CCâ/tool e-mail send to="admin@example.com" cc="manager@example.com" \ subject="Alert" body="Important notification"Send Parameters
Section titled âSend Parametersâ| Parameter | Description |
|---|---|
to | Recipient email (required) |
cc | CC recipients (comma-separated) |
subject | Email subject line |
body | Message body (plain text only) |
file | Attachment(s) (comma-separated) |
Part 3: Email Provider Setup
Section titled âPart 3: Email Provider SetupâGmail requires an App Password (16-character code):
- Go to Google Account â Security â 2-Step Verification â App Passwords
- Generate a new app password for âMailâ
- Use this password in RouterOS:
/tool e-mail set address=smtp.gmail.com port=587 tls=starttls \ from="yourname@gmail.com" user="yourname@gmail.com" \ password="xxxx-xxxx-xxxx-xxxx"Office 365
Section titled âOffice 365â- Enable SMTP AUTH in Office 365 Admin Center for the mailbox
- May need to disable security defaults or use app password
/tool e-mail set address=smtp.office365.com port=587 tls=starttls \ from="router@yourdomain.com" user="router@yourdomain.com" \ password="yourpassword"Provider Quick Reference
Section titled âProvider Quick Referenceâ| Provider | Server | Port | TLS |
|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | starttls |
| Gmail (SSL) | smtp.gmail.com | 465 | yes |
| Office 365 | smtp.office365.com | 587 | starttls |
| Outlook.com | smtp-mail.outlook.com | 587 | starttls |
| Yahoo | smtp.mail.yahoo.com | 587 | starttls |
Part 4: Automated Email Scripts
Section titled âPart 4: Automated Email ScriptsâBackup Email Script
Section titled âBackup Email ScriptâSend daily backup via email:
/system scheduler add name="daily-backup-email" interval=1d on-event={ /system backup save name=daily-backup :delay 2s /tool e-mail send to="admin@example.com" \ subject=([/system identity get name] . " Daily Backup") \ body=("Backup created: " . [/system clock get date]) \ file=daily-backup.backup}Netwatch Email Alert
Section titled âNetwatch Email AlertâSend email when host goes down or up:
/tool netwatch add host=8.8.8.8 interval=30s \ down-script={ /tool e-mail send to="admin@example.com" \ subject="ALERT: Host 8.8.8.8 DOWN" \ body=("Host went down at " . [/system clock get time]) } \ up-script={ /tool e-mail send to="admin@example.com" \ subject="RECOVERED: Host 8.8.8.8 UP" \ body=("Host recovered at " . [/system clock get time]) }System Status Report
Section titled âSystem Status Reportâ:local cpuload [/system resource get cpu-load]:local freemem [/system resource get free-memory]:local uptime [/system resource get uptime]:local name [/system identity get name]
/tool e-mail send to="admin@example.com" \ subject="$name Status Report" \ body="CPU Load: $cpuload%\nFree Memory: $freemem\nUptime: $uptime"Error Handling
Section titled âError Handlingâ:do { /tool e-mail send to="admin@example.com" subject="Alert" body="Message"} on-error={ :log warning "Email send failed"}Part 5: Advanced Configuration
Section titled âPart 5: Advanced ConfigurationâOverride Server Per-Send
Section titled âOverride Server Per-SendâSend via different server without changing global config:
/tool e-mail send to="admin@example.com" \ server=smtp.backup.com port=587 tls=starttls \ user="backup@backup.com" password="backuppass" \ subject="Via Backup Server" body="Sent through backup SMTP"Using IP Instead of Hostname
Section titled âUsing IP Instead of HostnameâSome configurations require IP address:
# Resolve hostname:put [:resolve smtp.gmail.com]
# Use IP in config/tool e-mail set address=74.125.136.108Certificate Verification
Section titled âCertificate VerificationâFor self-signed certificates:
/tool e-mail set certificate-verification=noTroubleshooting
Section titled âTroubleshootingâProblem 1: Gmail âAUTH Failedâ
Section titled âProblem 1: Gmail âAUTH FailedââSymptom: Authentication error with Gmail.
Cause: Using regular Gmail password; OAuth2 not supported.
Solution: Generate App Password:
- Go to Google Account â Security
- Enable 2-Step Verification
- Go to App Passwords â Generate
- Use the 16-character code as password
Problem 2: TLS Handshake Failed
Section titled âProblem 2: TLS Handshake FailedâSymptom: âTLS handshake failedâ error.
Cause: Wrong TLS mode for the port.
Solution:
- Port 587: Use
tls=starttls - Port 465: Use
tls=yes - Port 25: Use
tls=no(not recommended)
Problem 3: Connection Timeout
Section titled âProblem 3: Connection TimeoutâSymptoms: Email send times out or hangs.
Causes:
- Firewall blocking outbound SMTP
- DNS resolution failure
- Wrong server address or port
Solutions:
# Test DNS resolution:put [:resolve smtp.gmail.com]
# Test connectivity/tool fetch url="https://smtp.gmail.com" keep-result=no
# Try using IP instead of hostname/tool e-mail set address=74.125.136.108Problem 4: Email Not Received
Section titled âProblem 4: Email Not ReceivedâSymptom: No errors but email doesnât arrive.
Causes:
- Spam filtering
- SPF/DKIM failures
- Relay restrictions
Solutions:
- Check spam/junk folder
- Verify SPF records for sending domain
- Use authenticated SMTP relay
Problem 5: Netwatch Email Fails on Link Down
Section titled âProblem 5: Netwatch Email Fails on Link DownâSymptom: Down notification doesnât send.
Cause: Trying to send email over the link thatâs down.
Solutions:
- Use backup route for SMTP server
- Add delay for failover:
:delay 10sbefore send - Send via different interface
Problem 6: Office 365 Authentication Failed
Section titled âProblem 6: Office 365 Authentication FailedâSymptom: Cannot authenticate to Office 365.
Cause: SMTP AUTH disabled by default.
Solution:
- Go to Microsoft 365 Admin Center
- Users â Active Users â Select user
- Mail â Email apps â Enable âAuthenticated SMTPâ
Verification Commands
Section titled âVerification Commandsâ# Check email configuration/tool e-mail print
# Send test email/tool e-mail send to="test@example.com" subject="Test" body="Test message"
# Check logs for email activity/log print where topics~"e-mail"
# Enable debug logging/system logging add topics=e-mail,debug action=memoryRelated Topics
Section titled âRelated TopicsâAutomation
Section titled âAutomationâCommon Email Uses
Section titled âCommon Email Usesâ- System Backup - email backup notifications
- Logging - email on critical log events
- VRRP - failover notifications
Prerequisites
Section titled âPrerequisitesâ- DNS Server - DNS for SMTP server resolution
- NTP Client - accurate timestamps
Reference
Section titled âReferenceâOfficial Documentation
Section titled âOfficial DocumentationâQuick Reference Commands
Section titled âQuick Reference Commandsâ# Configure SMTP/tool e-mail set address=smtp.server.com port=587 tls=starttls \ from="router@domain.com" user="user@domain.com" password="pass"
# View configuration/tool e-mail print
# Send basic email/tool e-mail send to="admin@domain.com" subject="Subject" body="Message"
# Send with attachment/tool e-mail send to="admin@domain.com" subject="Backup" file=backup.backup
# Send with override settings/tool e-mail send to="admin@domain.com" server=alt.smtp.com port=587 \ user="altuser" password="altpass" subject="Test" body="Via alternate server"v6 Syntax Differences
Section titled âv6 Syntax Differencesâ# v6 TLS configuration/tool e-mail set start-tls=yes port=587# or for implicit TLS/tool e-mail set start-tls=tls-only port=465Summary
Section titled âSummaryâEmail Tool enables notifications and alerts from RouterOS:
- SMTP setup - Configure server, port, TLS, and credentials
- Gmail/O365 - Require App Passwords (OAuth2 not supported)
- Send emails - Basic messages, attachments, CC recipients
- Automation - Scheduler, Netwatch, and script integration
- Troubleshooting - Check TLS mode, firewall, DNS, and spam filters
Key points:
- Use
tls=starttlsfor port 587,tls=yesfor port 465 - Gmail/Office365 require App Passwords, not regular passwords
- Add
:delay 2safter creating files before sending as attachments - Netwatch down alerts may fail if sending over the down link
- Only plain text emails are supported (no HTML)