Skip to content
MikroTik RouterOS Docs

Email Tool

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.backup

Gmail/Office365

Gmail and Office365 require App Passwords, not regular passwords. OAuth2 is not supported by RouterOS.

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:

  1. Configure SMTP server settings (/tool e-mail set)
  2. Send emails using /tool e-mail send
  3. 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)

/tool e-mail set address=smtp.yourdomain.com port=587 tls=starttls \
from="MikroTik Router <router@yourdomain.com>" \
user="router@yourdomain.com" password="yourpassword"
ParameterDefaultDescription
address0.0.0.0SMTP server address
port25SMTP server port
user(empty)Authentication username
password(empty)Authentication password
from<>Sender email address
tlsnoEncryption: no/yes/starttls
ModePortDescription
no25No encryption (not recommended)
starttls587Upgrade to TLS after connecting
yes465Implicit TLS from start
/tool e-mail print

Example output:

address: smtp.gmail.com
port: 587
from: router@gmail.com
user: yourname@gmail.com
password: ****************
tls: starttls

/tool e-mail send to="admin@example.com" subject="Test Email" \
body="This is a test message from MikroTik"
/tool e-mail send to="admin@example.com" subject="Router Backup" \
body="Daily backup attached" file=router-backup.backup
/tool e-mail send to="admin@example.com" subject="Router Files" \
file=export.rsc,router-backup.backup
/tool e-mail send to="admin@example.com" cc="manager@example.com" \
subject="Alert" body="Important notification"
ParameterDescription
toRecipient email (required)
ccCC recipients (comma-separated)
subjectEmail subject line
bodyMessage body (plain text only)
fileAttachment(s) (comma-separated)

Gmail requires an App Password (16-character code):

  1. Go to Google Account → Security → 2-Step Verification → App Passwords
  2. Generate a new app password for “Mail”
  3. 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"
  1. Enable SMTP AUTH in Office 365 Admin Center for the mailbox
  2. 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"
ProviderServerPortTLS
Gmailsmtp.gmail.com587starttls
Gmail (SSL)smtp.gmail.com465yes
Office 365smtp.office365.com587starttls
Outlook.comsmtp-mail.outlook.com587starttls
Yahoosmtp.mail.yahoo.com587starttls

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
}

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])
}
: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"
:do {
/tool e-mail send to="admin@example.com" subject="Alert" body="Message"
} on-error={
:log warning "Email send failed"
}

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"

Some configurations require IP address:

# Resolve hostname
:put [:resolve smtp.gmail.com]
# Use IP in config
/tool e-mail set address=74.125.136.108

For self-signed certificates:

/tool e-mail set certificate-verification=no

Symptom: Authentication error with Gmail.

Cause: Using regular Gmail password; OAuth2 not supported.

Solution: Generate App Password:

  1. Go to Google Account → Security
  2. Enable 2-Step Verification
  3. Go to App Passwords → Generate
  4. Use the 16-character code as password

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)

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.108

Symptom: No errors but email doesn’t arrive.

Causes:

  • Spam filtering
  • SPF/DKIM failures
  • Relay restrictions

Solutions:

  1. Check spam/junk folder
  2. Verify SPF records for sending domain
  3. Use authenticated SMTP relay

Symptom: Down notification doesn’t send.

Cause: Trying to send email over the link that’s down.

Solutions:

  1. Use backup route for SMTP server
  2. Add delay for failover: :delay 10s before send
  3. Send via different interface

Symptom: Cannot authenticate to Office 365.

Cause: SMTP AUTH disabled by default.

Solution:

  1. Go to Microsoft 365 Admin Center
  2. Users → Active Users → Select user
  3. Mail → Email apps → Enable “Authenticated SMTP”

# 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=memory
  • Scheduler - time-based email automation
  • Netwatch - host monitoring with email alerts
# 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 TLS configuration
/tool e-mail set start-tls=yes port=587
# or for implicit TLS
/tool e-mail set start-tls=tls-only port=465

Email Tool enables notifications and alerts from RouterOS:

  1. SMTP setup - Configure server, port, TLS, and credentials
  2. Gmail/O365 - Require App Passwords (OAuth2 not supported)
  3. Send emails - Basic messages, attachments, CC recipients
  4. Automation - Scheduler, Netwatch, and script integration
  5. Troubleshooting - Check TLS mode, firewall, DNS, and spam filters

Key points:

  • Use tls=starttls for port 587, tls=yes for port 465
  • Gmail/Office365 require App Passwords, not regular passwords
  • Add :delay 2s after 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)