Community discussions

MikroTik App
 
unique82
just joined
Topic Author
Posts: 16
Joined: Mon Jul 22, 2013 3:59 pm

Manual:Tools/email - how to identify device which sent email

Thu Feb 09, 2023 4:53 pm

Hi,
simply question is there a way to identify from which router email has been sent if you have more that ONE mikrotik device ? :DD I find it ridiculous :P
And manual isn't very much helpfull as well so field "from" does show receiver or sender ? Because email is sent only when i put the same email address in there as is written in the field "user"
Does someone have any advice or am i just missing something ?

Sub-menu: /tool e-mail
from (string; Default: <>) Name or email address that will be shown as receiver.

Command: /tool e-mail send
from (string; Default: ) Name or email address which will appear as sender. If not specified value from server's configuration is used.

https://wiki.mikrotik.com/wiki/Manual:T ... Properties
 
unique82
just joined
Topic Author
Posts: 16
Joined: Mon Jul 22, 2013 3:59 pm

Re: Manual:Tools/email - how to identify device which sent email

Thu Feb 09, 2023 5:10 pm

Basically this as show on picture, thousands of mikrotik devices and they cant identify themselves when sending email ?
what i want to do is make an alarm for Cube60 when primary 60Ghz link goes down to send and device log to let us know that it's running on 5Ghz backup....seems like very hard to do without scripting :P
You do not have the required permissions to view the files attached to this post.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10550
Joined: Mon Jun 08, 2015 12:09 pm

Re: Manual:Tools/email - how to identify device which sent email

Thu Feb 09, 2023 5:30 pm

It depends on the e-mail service and the domain used. When you have your own e-mail domain and control its servers, you can set a proper From address in each router, e.g. make it the same as the ID, use the MAC address, serial number, whatever.
Of course when you use someone else's mail servers (e.g. gmail) you cannot set arbitrary From addresses or the will be rejected.
In some cases you can use the + in e-mail as a comment character, e.g. unique82+device1@gmail.com
Gmail will ignore the +device1 when delivering mail, but you can still see it in the mail message.
 
optio
Forum Veteran
Forum Veteran
Posts: 964
Joined: Mon Dec 26, 2022 2:57 pm

Re: Manual:Tools/email - how to identify device which sent email

Sat Feb 11, 2023 5:21 pm

You can append router name (or other identifier) into mail subject.
/tool/e-mail/send to=<to_address> subject=(<subject> . " [" . [/system/identity get name] . "]") body=<body>
 
User avatar
bpwl
Forum Guru
Forum Guru
Posts: 3134
Joined: Mon Apr 08, 2019 1:16 am

Re: Manual:Tools/email - how to identify device which sent email

Sat Feb 11, 2023 7:09 pm

As a non-specific answer for this MT sent e-mail.

Since 09/11 incident it is mandatory that the source IP address of the e-mail is always in the headers of that e-mail.

It can take some puzzling but the public and NATted sending device IP address can always be found in the headers. Fake and hidden mailers are easily found. (The ISP gave me the real physical address of the stalker)

I see that MT even adds the Router System Identity (eg. my hEX-Romarins)
Return-Path: <bpwl@...>
Received: from mailfep0...

Received: from <public IP **.**.**.**>.rev.sfr.net (HELO [192.168.95.100]) ([**.**.**.**])
  by relay.<ISP domain*********.**> with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2023 17:37:14 +0100
Date: Sat, 11 Feb 2023 17:37:14 +0100
From: bpwl@<enveloppe from *******.****>
Subject: test
To: bpwl@<destination domain *******.****>
Message-id: <825d6f98ae6eef44f635f03ae21498793238bb69-1@hEX-Romarins>
 
optio
Forum Veteran
Forum Veteran
Posts: 964
Joined: Mon Dec 26, 2022 2:57 pm

Re: Manual:Tools/email - how to identify device which sent email

Mon Feb 13, 2023 1:03 am

As a non-specific answer for this MT sent e-mail.

Since 09/11 incident it is mandatory that the source IP address of the e-mail is always in the headers of that e-mail.
Well, you can always try to send emails from local smtp, some badly configured email server will accept it. :)
Received: from localhost (Unknown [10.244.11.209])
	by 174931b69bad (Haraka/3.0.0) with ESMTP id B5F634EF-A203-4702-9E92-65AAB5E68FD9.1
	envelope-from <root@localhost>;
	Sun, 12 Feb 2023 22:48:02 +0000
Received: from unknown (localhost [IPv6:::1])
	by localhost (Postfix) with ESMTP id D4742E13EDAA
	for <...@...>; Sun, 12 Feb 2023 23:48:00 +0100 (CET)
Date: Sun, 12 Feb 2023 23:48:00 +0100
Message-ID: <898ce3b5acb468d9e2ec3f5e18455243.root@localhost>
From: Me <...@...>
Subject: Testis
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1589
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Manual:Tools/email - how to identify device which sent email

Mon Feb 13, 2023 4:40 am

I can set the From field in the E-Mail settings and it does work fine for me. This is on a RB4011iGS+ running 6.49.6
Image
or
/tool e-mail
set address=smtp.gmail.com from="RB4011iGS+ Router" password=<redacted> \
    port=587 start-tls=yes user=<redacted>@gmail.com
Additionally, as previously mentioned, you can add the router into a script that is sending the E-Mail into the subject or the body of the message.
/tool e-mail send file=RB4011_Daily.backup to="ji<redacted>g" body="4011 Router daily backup file attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Backup"
 
AidanAus
Member Candidate
Member Candidate
Posts: 177
Joined: Wed May 08, 2019 7:35 am
Location: Australia
Contact:

Re: Manual:Tools/email - how to identify device which sent email

Mon Feb 13, 2023 6:06 am

I can set the From field in the E-Mail settings and it does work fine for me. This is on a RB4011iGS+ running 6.49.6
Image
or
/tool e-mail
set address=smtp.gmail.com from="RB4011iGS+ Router" password=<redacted> \
    port=587 start-tls=yes user=<redacted>@gmail.com
Additionally, as previously mentioned, you can add the router into a script that is sending the E-Mail into the subject or the body of the message.
/tool e-mail send file=RB4011_Daily.backup to="ji<redacted>g" body="4011 Router daily backup file attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Backup"
If you dont know already google requires you to get an app password: https://support.google.com/accounts/answer/185833?hl=en
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1589
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Manual:Tools/email - how to identify device which sent email

Mon Feb 13, 2023 6:25 am

If you dont know already google requires you to get an app password: https://support.google.com/accounts/answer/185833?hl=en
If that was directed to me, yes, I am very much aware of that. I use several different gmail accounts from a bunch of different devices for sending E-Mails.