Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

An E-mail tool is the a utility that allows to send sending e-mails from the router. Tool The tool can be used to send regular configuration backups and exports to a network administrator.

Email tool uses only plain authentication and tls TLS encryption. Other methods are not supported.

...

Properties

...


Code Block
languageros
/tool e-mail

This submenu allows

...

setting SMTP server that will be used.

PropertyDescription
address (IP/IPv6 address; Default: 0.0.0.0)

SMTP server's IP address.

from (string; Default: <>)Name or email address that will be shown as a receiver.
password (string; Default: "")Password used for authenticate authenticating to an SMTP server.
port (integer[0..65535]; Default: 25)SMTP server's port.
start-tls (no|yes|tls-onlystarttls; Default: no)Whether to use tls TLS encryption:
  • yes   - sends STARTTLS and continue without TLS if server responds that drops the session if TLS is not available ;on the server
  • no - do not send STARTTLS;
  • tls-only starttls - sends STARTTLS and drops the session if continue without TLS if a server responds that TLS is not available on the server.
user (string; Default: "")Username The username used for authenticate authenticating to an SMTP server.

vrf (VRF name; default value: main)

Set VRF on which service is creating outgoing connections.


Note
Note: All server's configuration configurations (if specified) can be overridden by send command. If start-tls='''tls-only''', port 465 will be used

...

Sending Email

...


Code Block
languageros
/tool e-mail send

Send command takes the following parameters:

PropertyDescription
body (string; Default: )Actual The actual body of the email message
cc (string; Default: )Send a copy to listed recipients. Multiple addresses allowed, use "," to separate entries
file (File[,File]; Default: )List of the file names that will be attached to the mail separated by a comma.
from (string; Default: )Name or email address which will appear as the sender. If a not specified value from  the server's configuration is used.
password (string; Default: )Password used to authenticate to an SMTP server. If a not specified value from  the server's configuration is used.
port (integer[0..65535]; Default: )Port of SMTP server. If not specified, a value from  the server's configuration is used.
server (IP/IPv6 address; Default: )Ip or IPv6 address of SMTP server. If not specified, a value from  the server's configuration is used.
start-tls (yes|no|tls-onlystarttls; Default: no)Whether to use tls TLS encryption:
  • yes   - sends STARTTLS and continue without TLS if server responds that drops the session if TLS is not available ;on the server
  • no - do not send STARTTLS;
  • tlsstarttls - only - sends STARTTLS and drops the session if continue without TLS if a server responds that TLS is not available on the server.
subject (string; Default: )Subject The subject of the message.
to (string; Default: )Destination email address. Single address allowed.
user (string; Default: )Username The username used to authenticate to an SMTP server. If not specified, a value from  the server's configuration is used.

...

Basic examples

...

This example will show how to send an email with configuration export every 24hours.

1. Configure SMTP server

Code Block
languageros
[admin@MikroTik] /tool e-mail> set server=10.1.1.1 port=25 from="router@mydomain.com"

...

2. Add a new script named "export-send":

Code Block
languageros
/export file=export 
/tool e-mail send to="config@mydomain.com" subject="$[/system identity get name]

...

 export" \ 
body="$[/system clock get date] configuration file" file=export.rsc

...

3. Add scheduler to run our script:

Code Block
languageros
/system scheduler

...

 add on-event="export-send" start-time=00:00:00 interval=24h

...

info


Send e-mail to a server using TLS/SSL encryption. For example, Google mail requires that.



Info

After the Google mail added a new security policy that does not allow 3d-party devices to authenticate using your standard Gmail password → you need to generate a 16-digit passcode ("App" password) and use it instead of your Gmail password. To configure this, navigate to the "Security>Signing in to Google" section settings and:

  • Enable 2-Step Verification;
  • Generate an App password.

Use the newly generated App password in the "set password=mypassword" setting shown below.


1. configure a client to connect to the correct server:

Code Block
languageros
/tool e-mail 
set address=

...

smtp.

...

gmail.

...

com
set port=

...

465
set tls=yes 
set from=myuser@gmail.com 
set user=myuser 
set password=mypassword

...

2. send e-mail using send command with tls attribute set to yes:

Code Block
languageros
/tool e-mail send to=myuser@anotherdomain.com subject="email test" body="email test" 

...