Community discussions

MikroTik App
 
cairoapcampos
just joined
Topic Author
Posts: 12
Joined: Sat Nov 25, 2023 2:58 am

How can Mikrotik/RouterOS send emails using Gmail?

Mon Nov 27, 2023 5:04 pm

I'm trying to configure Gmail smtp on RouterOS. I generated the application password in the account but it still didn't work. I made the two configurations below:

Test 1:

/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

/tool e-mail send to=myuser@gmail.com subject="email test" body="email test"

Test 2:

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

/tool e-mail send to=myuser@gmail.com subject="email test" body="email test" start-tls=yes

As I was only testing the source and destination email is the same. As I said before, neither test worked. Does Gmail still work for notifications and backup?

Links used:

https://stackoverflow.com/questions/615 ... l-mikrotik

https://help.mikrotik.com/docs/display/ROS/E-mail

https://wiki.mikrotik.com/wiki/Manual:Tools/email
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1506
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: How can Mikrotik/RouterOS send emails using Gmail?

Mon Nov 27, 2023 8:17 pm

Each of my routers sends multiple E-Mails per day via G-Mail. Here is my E-mail setup:
/tool e-mail
set address=smtp.gmail.com from="RB4011iGS+ Router" password=mypasswordhere \
    port=587 start-tls=yes user=userid@gmail.com
And here is an extract from a script that uses the E-Mail to send a backup file
/tool e-mail send file=RB4011_Daily.backup to="jim@myDomain" body="4011 Router daily backup file attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Backup"
 
cairoapcampos
just joined
Topic Author
Posts: 12
Joined: Sat Nov 25, 2023 2:58 am

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:08 pm

Each of my routers sends multiple E-Mails per day via G-Mail. Here is my E-mail setup:
/tool e-mail
set address=smtp.gmail.com from="RB4011iGS+ Router" password=mypasswordhere \
    port=587 start-tls=yes user=userid@gmail.com
And here is an extract from a script that uses the E-Mail to send a backup file
/tool e-mail send file=RB4011_Daily.backup to="jim@myDomain" body="4011 Router daily backup file attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Backup"
I will try to configure the email service again according to your tip.

Another doubt. In addition to the ".backup" file, can you email an encrypted ".rsc" export file?
 
cairoapcampos
just joined
Topic Author
Posts: 12
Joined: Sat Nov 25, 2023 2:58 am

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:24 pm

I tried sending the email according to the example and it didn't work.
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1506
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:33 pm

Another doubt. In addition to the ".backup" file, can you email an encrypted ".rsc" export file?
I E-Mail a backup, Export and a Version text file every night. I addition messages extracted from the log when someone logs in or out, or a port knock sequence completes. Additionally a status message when the router boots, and results of some regular ping tests.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3565
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:37 pm

What version of RouterOS and winbox are you using? There is a difference in the options some combo of routeros/winbox that adds even more confusion. I suspect if you try tls=starttls and port=587 at the CLI, it should work if V7.

See: viewtopic.php?p=987607&hilit=gmail+e+mail#p987607
 
ros44
Frequent Visitor
Frequent Visitor
Posts: 74
Joined: Sun Feb 25, 2018 2:05 am
Location: Sofia, Bulgaria

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:49 pm

Enable 2FA for your Gmail account. Then generate an App passwords and use that password in your MikroTik config.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3565
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 8:51 pm

Enable 2FA for your Gmail account. Then generate an App passwords and use that password in your MikroTik config.
Oh that could be it too. The how to enable the "app password" is in Mikrotik's docs: https://help.mikrotik.com/docs/display/ ... icexamples
 
cairoapcampos
just joined
Topic Author
Posts: 12
Joined: Sat Nov 25, 2023 2:58 am

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 11:31 pm

What version of RouterOS and winbox are you using? There is a difference in the options some combo of routeros/winbox that adds even more confusion. I suspect if you try tls=starttls and port=587 at the CLI, it should work if V7.

See: viewtopic.php?p=987607&hilit=gmail+e+mail#p987607
RouterOS version is 6.49.10. I'm testing on a CHR X86 VM, but I intend to do the same configuration on a Routerboard that has the same version of RouterOS.
 
cairoapcampos
just joined
Topic Author
Posts: 12
Joined: Sat Nov 25, 2023 2:58 am

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 11:33 pm

Enable 2FA for your Gmail account. Then generate an App passwords and use that password in your MikroTik config.
Oh that could be it too. The how to enable the "app password" is in Mikrotik's docs: https://help.mikrotik.com/docs/display/ ... icexamples
I already enabled 2FA on my Gmail account, but it didn't work.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3565
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: How can Mikrotik/RouterOS send emails using Gmail?

Tue Nov 28, 2023 11:50 pm

What version of RouterOS and winbox are you using? There is a difference in the options some combo of routeros/winbox that adds even more confusion. I suspect if you try tls=starttls and port=587 at the CLI, it should work if V7.

See: viewtopic.php?p=987607&hilit=gmail+e+mail#p987607
RouterOS version is 6.49.10. I'm testing on a CHR X86 VM, but I intend to do the same configuration on a Routerboard that has the same version of RouterOS.

The "tls=" syntax is a V7 thing — so my example was wrong... but either of these should work (assuming user= and password=<gmail_app_password> are also set):

/tool e-mail set start-tls=yes port=587

OR

/tool e-mail set start-tls=tls-only port=587

If it's authentication error, something should show up in the log AFAIK. Also, you might also want to check your firewall filters, maybe the output traffic is dropped?
 
wfburton
Frequent Visitor
Frequent Visitor
Posts: 81
Joined: Mon Apr 10, 2023 1:09 am

Re: How can Mikrotik/RouterOS send emails using Gmail?

Wed Nov 29, 2023 12:18 am

You need to log into your gmail account and create a app password.

Go to Security then 2-Step Verification and App passwords.

At the bottom create a app password like mikrotik. You will get a pop-up with your app password. Copy and paste that for you password in you router e-mail password. Make sure you save it, You can't view it afterwards. You will have to delete it and create a new app password again.

Done
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1506
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: How can Mikrotik/RouterOS send emails using Gmail?

Wed Nov 29, 2023 8:09 am

Just FYI, the code examples I gave earlier are from a router running 6.49.10.

Who is online

Users browsing this forum: F3BOli and 46 guests