Manual:Tools/email: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
Created page with '{{Versions|v3, v4, v5}} <div class=manual> ==Summary== <p> E-mail tool is the utility that allows to send e-mails from the router. Tool can be used to send regular configuratio…'
 
MatissO (talk | contribs)
 
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Versions|v3, v4, v5}}
{{Versions|v3, v4, v5 +}}


<div class=manual>


==Summary==
==Summary==
<p>
 
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.  
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.  
</p>
 
<p>
Email tool uses only plain authentication and tls encryption. Other methods are not supported.
Email tool uses only plain authentication and tls encryption. Other methods are not supported.
</p>




==Properties==
==Properties==
<p><b>Sub-menu:</b> <code>/tool e-mail</code></p>
<p id="shbox"><b>Sub-menu:</b> <code>/tool e-mail</code></p>
 


<p>
This submenu allows to set smtp server that will be used.
This submenu allows to set smtp server that will be used.
</p>
 
{{Mr-arg-table-h
{{Mr-arg-table-h
|prop=Property
|prop=Property
|desc=Description
|desc=Description
}}
{{Mr-arg-table
|arg=address
|type=IP/IPv6 address
|default=0.0.0.0
|desc=SMTP server's IP address.
}}
}}


Line 28: Line 32:
|default=<>
|default=<>
|desc=Name or email address that will be shown as receiver.  
|desc=Name or email address that will be shown as receiver.  
}}
}}


Line 36: Line 39:
|default=""
|default=""
|desc=Password used for authenticate to SMTP server.
|desc=Password used for authenticate to SMTP server.
}}


{{Mr-arg-table
|arg=port
|type=integer[0..65535]
|default=25
|desc=SMTP server's port.
}}
}}


{{Mr-arg-table
{{Mr-arg-table
|arg=server
|arg=start-tls
|type=IP:Port
|type=no{{!}}yes{{!}}tls-only
|default=0.0.0.0:25
|default=no
|desc=SMTP server's IP address and port.
|desc=Whether to use tls encryption:
 
* <var>yes</var> - sends STARTTLS and continue without TLS if server responds that TLS is not available;
* <var>no</var> - do not send STARTTLS;
* <var>tls-only</var> - sends STARTTLS and drops the session if TLS is not available on the server.  
}}
}}


{{Mr-arg-table
{{Mr-arg-table-end
|arg=username
|arg=user
|type=string
|type=string
|default=""
|default=""
Line 55: Line 66:
}}
}}


</table>


{{Note | All server's configuration (if specified) can be overridden by [[#Send | send]] command. }}
{{Note | All server's configuration (if specified) can be overridden by [[#Send | send]] command.}}
 
==Sending Email==
 
<p id="shbox"><b>Command:</b> <code>/tool e-mail send</code></p>


==Send==
<p>
Email is sent using following command <code>/tool e-mail send</code>
</p>


Send command takes following parameters:
Send command takes following parameters:
Line 76: Line 86:
|default=
|default=
|desc=Actual body of the email message
|desc=Actual body of the email message
}}
{{Mr-arg-table
|arg=cc
|type=string
|default=
|desc=Send a copy to listed recipients. Multiple addresses allowed, use "," to separate entries
}}
}}


{{Mr-arg-table
{{Mr-arg-table
|arg=file
|arg=file
|type=string
|type=File[,File]
|default=
|default=
|desc=Name of the file that will be attached to the email. Only one file can be attached.
|desc=List of the file names that will be attached to the mail separated by comma.
}}
}}


Line 98: Line 115:
|default=
|default=
|desc=Password used to authenticate to SMTP server. If not specified value from [[#Properties | server's configuration]] is used.
|desc=Password used to authenticate to SMTP server. If not specified value from [[#Properties | server's configuration]] is used.
}}
{{Mr-arg-table
|arg=port
|type=integer[0..65535]
|default=
|desc=Port of SMTP server. If not specified, value from [[#Properties | server's configuration]] is used.


}}
}}
Line 103: Line 129:
{{Mr-arg-table
{{Mr-arg-table
|arg=server
|arg=server
|type=IP:Port
|type=IP/IPv6 address
|default=
|default=
|desc=Ip address and port of SMTP server. If not specified value from [[#Properties | server's configuration]] is used.
|desc=Ip or IPv6 address of SMTP server. If not specified, value from [[#Properties | server's configuration]] is used.
}}


{{Mr-arg-table
|arg=start-tls
|type=yes{{!}}no{{!}}tls-only
|default=no
|desc=Whether to use tls encryption:
* <var>yes</var> - sends STARTTLS and continue without TLS if server responds that TLS is not available;
* <var>no</var> - do not send STARTTLS;
* <var>tls-only</var> - sends STARTTLS and drops the session if TLS is not available on the server.
}}
}}


Line 114: Line 149:
|default=
|default=
|desc=Subject of the message.
|desc=Subject of the message.
}}
}}


{{Mr-arg-table
|arg=tls
|type=<nowiki>yes|no</nowiki>
|default=yes
|desc=Whether to use tls encryption or not.
}}


{{Mr-arg-table
{{Mr-arg-table
Line 129: Line 156:
|type=string
|type=string
|default=
|default=
|desc=Destination email address
|desc=Destination email address. Single address allowed.


}}
}}


{{Mr-arg-table
{{Mr-arg-table-end
|arg=user
|arg=user
|type=string
|type=string
|default=
|default=
|desc=Username used to authenticate to SMTP server. If not specified value from [[#Properties | server's configuration]] is used.
|desc=Username used to authenticate to SMTP server. If not specified, value from [[#Properties | server's configuration]] is used.


}}
}}
</table>


==Basic examples==


==Basic examples==
<p>
This example will show how to send email with configuration export every 24hours.
This example will show how to send email with configuration export every 24hours.
</p>


<p>
 
 
1. Configure SMTP server
1. Configure SMTP server
<pre>
<pre>
[admin@MikroTik] /tool e-mail> set server=10.1.1.1:25 from="router@mydomain.com"
[admin@MikroTik] /tool e-mail> set server=10.1.1.1 port=25 from="router@mydomain.com"
</pre>
</pre>
2. Add new [[M:Scripting#Script_repository | script]] named "export-send"
2. Add new [[M:Scripting#Script_repository | script]] named "export-send"
<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>
Line 164: Line 189:
add on-event="export-send" start-time=00:00:00 interval=24h
add on-event="export-send" start-time=00:00:00 interval=24h
</pre>
</pre>
</p>
 
 
 
Send e-mail to server using TLS/SSL encryption. For example, Google mail requires that.
 
 
1. configure client to connect to correct server
<pre>
/tool e-mail
set address=173.194.77.108
set port=587
set from=myuser@gmail.com
set user=myuser
set password=mypassword
</pre>
 
2. send e-mail using send command with tls attribute set to yes
 
<pre>
send to=myuser@anotherdomain.com subject="email test" body="email test" start-tls=yes
</pre>
 
 
 
{{cont}}
{{cont}}


</div>


[[Category:Manual|E]]
[[Category:Manual|E]]
[[Category:Tools|E]]

Latest revision as of 14:27, 8 March 2023

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
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 receiver.
password (string; Default: "") Password used for authenticate to SMTP server.
port (integer[0..65535]; Default: 25) SMTP server's port.
start-tls (no|yes|tls-only; Default: no) Whether to use tls encryption:
  • yes - sends STARTTLS and continue without TLS if server responds that TLS is not available;
  • no - do not send STARTTLS;
  • tls-only - sends STARTTLS and drops the session if TLS is not available on the server.
user (string; Default: "") Username used for authenticate to SMTP server.


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. 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 comma.
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.
start-tls (yes|no|tls-only; Default: no) Whether to use tls encryption:
  • yes - sends STARTTLS and continue without TLS if server responds that TLS is not available;
  • no - do not send STARTTLS;
  • tls-only - sends STARTTLS and drops the session if TLS is not available on the server.
subject (string; Default: ) Subject of the message.
to (string; Default: ) Destination email address. Single address allowed.
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" start-tls=yes


[ Top | Back to Content ]