Manual:Tools/email: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
m (→‎Basic examples: thanks suerfertim for clear example)
Line 173: Line 173:
<pre>
<pre>
/export file=export
/export file=export
/tool e-mail send to="config@mydomain.com" subject="$[/system identity get name]  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
body="$[/system clock get date] configuration file" file=export.rsc
</pre>
</pre>

Revision as of 05:14, 30 August 2016

Version.png

Applies to RouterOS: v3, v4, v5 +


Summary

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

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


Properties

Sub-menu: /tool e-mail


This submenu allows to set smtp server that will be used.

Property Description
from (string; Default: <>) Name or email address that will be shown as receiver.
password (string; Default: "") Password used for authenticate to SMTP server.
address (IP/IPv6 address; Default: 0.0.0.0) SMTP server's IP address.
port (integer[0..65535]; Default: 25) SMTP server's port.
username (string; Default: "") Username used for authenticate to SMTP server.


Icon-note.png

Note: All server's configuration (if specified) can be overridden by send command.


Sending Email

Command: /tool e-mail send


Send command takes following parameters:

Property Description
body (string; Default: ) Actual body of the email message
cc (string; Default: ) Send a copy to listed recipients.
file (string; Default: ) Name of the file that will be attached to the email. Only one file can be attached.
from (string; Default: ) Name or email address which will appear as sender. If not specified value from server's configuration is used.
password (string; Default: ) Password used to authenticate to SMTP server. If not specified value from server's configuration is used.
port (integer[0..65535]; Default: ) Port of SMTP server. If not specified, value from server's configuration is used.
server (IP/IPv6 address; Default: ) Ip or IPv6 address of SMTP server. If not specified, value from server's configuration is used.
subject (string; Default: ) Subject of the message.
tls (yes|no; Default: yes) Whether to use tls encryption or not.
to (string; Default: ) Destination email address
user (string; Default: ) Username used to authenticate to SMTP server. If not specified, value from server's configuration is used.

Basic examples

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


1. Configure SMTP server

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

2. Add new script named "export-send"

/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

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


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


1. configure client to connect to correct server

/tool e-mail
set address=173.194.77.108
set port=587
set from=myuser@gmail.com
set user=myuser
set password=mypassword

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

send to=myuser@anotherdomain.com subject="email test" body="email test" tls=yes


[ Top | Back to Content ]