Community discussions

MikroTik App
 
pepelxl
just joined
Topic Author
Posts: 23
Joined: Tue Jul 23, 2013 6:59 pm

status of the sent email?

Fri Jul 19, 2019 4:45 pm

Is it possible to check the status of the sent email?
Learn the script execution status, example:
/tool e-mail send to=exemple@mail.ru subject="Mikrotik" body=hello
:if (email send....) do=
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: status of the sent email?  [SOLVED]

Sat Jul 20, 2019 12:19 am

:if ([ /tool e-mail get last-status ] = "succeeded") do={ ...
But I am not sure if you need a delay between sending and checking for status...
 
pepelxl
just joined
Topic Author
Posts: 23
Joined: Tue Jul 23, 2013 6:59 pm

Re: status of the sent email?

Sat Jul 20, 2019 8:03 am

Thanks you.
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: status of the sent email?

Mon Dec 02, 2019 8:24 pm

With waiting loop until "in-progress" will change.
{
# Wait until other script in bg end sending e-mail now...
while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
delay 2s

# Now I send my e-mail who has wrong smtp server and reach timeout...
tool e-mail send server=1.1.1.1 subject="WrongSMTP" to=name@domain.tld
while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
local EMailStatus [tool e-mail get last-status]
if ($EMailStatus = "failed") do={put "ERROR"}
if ($EMailStatus = "succeeded") do={put "SUCCESS"}
}
OR
{
tool e-mail send server=1.1.1.1 subject="WrongSMTP" to=name@domain.tld
local ExitDoLoop false
while ($ExitDoLoop = false) do={
  local EMailStatus [tool e-mail get last-status];
  if ($EMailStatus = "in-progress") do={delay 1s; put "."} else={
    set $ExitDoLoop true;
    if ($EMailStatus = "failed") do={put "ERROR"}
    if ($EMailStatus = "succeeded") do={put "SUCCESS"}
  }
}
}
 
User avatar
pothi
newbie
Posts: 46
Joined: Fri Sep 14, 2018 7:48 pm
Location: Srivilliputhur, Tamil Nadu, India
Contact:

Re: status of the sent email?

Sun Feb 27, 2022 7:36 am

Thank you, SiB.

Your while loop works. However, I modified it to "do-while" in order to give a second of delay for the email to send to track its progress...
:do { :delay 1s } while=( [/tool e-mail get last-status] = "in-progress" )

Who is online

Users browsing this forum: No registered users and 13 guests