Email

RouterOS 中的 E-mail 工具使设备能够使用带明文身份验证或 TLS 加密的 SMTP 直接从设备发送电子邮件,支持计划备份和可自定义的电子邮件内容。它允许通过 /tool/e-mail 子菜单配置 SMTP 服务器、身份验证详细信息、加密设置和附件处理。

电子邮件

电子邮件工具是 RouterOS 内置实用工具,使路由器能够直接从设备发送电子邮件消息。它可用于按计划自动将配置备份和导出文件传递给网络管理员。

电子邮件工具支持明文身份验证和 TLS 加密。不支持其他身份验证或加密方法。

配置

SMTP 服务器在 /tool/e-mail 菜单中配置。

所有服务器设置都可以由 send 命令的参数覆盖。

发送电子邮件

电子邮件使用 /tool/e-mail/send 命令发送。send 命令中未指定的任何参数都从服务器配置继承其值。

基本示例

每 24 小时发送一次配置导出。

  1. 配置 SMTP 服务器。
[admin@MikroTik] /tool/e-mail> set server=10.1.1.1 port=25 from="router@mydomain.com"
  1. 添加一个名为 "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
  1. 添加一个调度器来运行脚本。
/system/scheduler/add on-event="export-send" start-time=00:00:00 interval=24h

使用 TLS 加密向服务器发送电子邮件。

信息

Google Mail 不允许第三方设备使用标准 Gmail 密码进行身份验证。必须生成并使用应用密码。

要生成应用密码,请导航到 Security > How you sign in to Google,启用两步验证,然后生成应用密码。在下面显示的 set password=mypassword 设置中使用生成的值。

  1. 配置客户端。
/tool/e-mail 
set address=smtp.gmail.com
set port=587
set tls=yes 
set from=myuser@gmail.com 
set user=myuser 
set password=mypassword
  1. 使用 send 命令发送电子邮件。
/tool/e-mail/send to=myuser@anotherdomain.com subject="email test" body="email test"