Community discussions

MikroTik App
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:05 pm

Hi,
I added email settings via Tools > Email and then in Send Email. Its working perfectly when I send email (see snapshot).

I then added script in Tool > Traffic Monitor and I set threshold 1M

But when I try to send email via terminal or using script but its not working.
/tool e-mail send to=myuser@domain subject="test" body="test"
I tried this as well
/tool e-mail send to="myuser@domain" subject="Download" \
body="$[/system clock get date] - $[/system clock get time]"
Also
/tool e-mail set address=mailserver port=587 from=user user=user@mailsesrver password=sasa start-tls=yes
/tool e-mail send to=tome@mailserver subject="test" body="test"
I am receiving Error sending email, error connecting to server in logs.

Mikrotic Device: RB3011UiAS
Version: 6.43.16 (long-term)

Thanks in advance
You do not have the required permissions to view the files attached to this post.
Last edited by mohamadjacob on Thu Jul 15, 2021 3:31 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:26 pm

...
Last edited by rextended on Thu Jul 15, 2021 3:32 pm, edited 1 time in total.
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:30 pm

I'm using the same settings as on main settings. still not connecting/sending email.

Thanks will consider to upgrade. Should I use stable version or LT?
Last edited by mohamadjacob on Thu Jul 15, 2021 3:32 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:32 pm

First: upgrade your device, is ridicoulusly old... 6.43.16 from 2019/05/15 and full of backdoor.

I suggest everytime the long-term 6.47.10

Second: on picture you use different settings for sending test mail...
You do not think to use THAT settings on main settings?

start-tls=yes ≠ start-tls=tls-only
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:36 pm

I tried with tls and without tls. The thing is its sending email when I press send email.

But its not working on terminal and in script.

So I'm thinking it might work after upgrade.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 3:48 pm

Try with start-tls=no (or =tls-only) ?
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Re: Error Sending Email via Terminal and Script

Thu Jul 15, 2021 4:13 pm

I tried via terminal with tls option and without tls.

Same error

Error sending email. Error connecting to server

Update: Upgraded to 6.47.10 LT
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Re: Error Sending Email via Terminal and Script

Sun Jul 18, 2021 2:13 pm

Hi,
I tested again today by sending an email via GUI (Tools > Email > Send Mail) and then I checked it and I received to my email address.

[@MikroTik] > /tool e-mail print
address: mail.domain.com
port: 587
start-tls: yes
from: notification@domain.com
user: notification@domain.com
password: ----
last-status: succeeded

But failing on terminal.

Update:
I tried this command (with mail server IP as well)

/tool e-mail send to="me@domain.com" subject="test" \
from="notification@domain.com" server="mail.domain.com:587" \
user="notification@domain.com" password="---"

In logs, it says
Error sending e-mail <test>: DNS resolve failed

Any idea how to resolve?
Thanks
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Error Sending Email via Terminal and Script

Mon Jul 19, 2021 5:47 am

server="mail.domain.com:587" ???

server="mail.domain.com" port=587 ???
 
mohamadjacob
just joined
Topic Author
Posts: 12
Joined: Wed Jul 11, 2018 12:14 am

Re: Error Sending Email via Terminal and Script  [SOLVED]

Thu Jul 29, 2021 1:30 pm

Thanks for the reply,

Some how I used IP of mail sever again today and it worked via terminal

Who is online

Users browsing this forum: ko00000000001 and 22 guests