email sent from mikrotik to may sim smtp connections need de

:global uptime
:global count
:global usrname
:global clientname
:global clientsurname
:global poolname
:global accounttype
:global discount
:global amount
:global discountedamount
:global discountcheck
:global date
:global invoice
:global nextinvoicenumber
:global bytesin
:global bytesout
:global bytestotal
:global gigstotal
:global email
:global basecharge
:global usagecharge
:global total
:global disabled
:global doespay
:global server
:global newcomment
:global comment
:global cap
:global warning
:global lastinvoicemonth
:global month
:global monthnum
:global newmonthnum
:global lastmonth

:set month [:pick [/system clock get date] 0 3]

:if ([$month] = jan) do={ :set newmonthnum 01 }
:if ([$month] = feb) do={ :set newmonthnum 02 }
:if ([$month] = mar) do={ :set newmonthnum 03 }
:if ([$month] = apr) do={ :set newmonthnum 04 }
:if ([$month] = may) do={ :set newmonthnum 05 }
:if ([$month] = jun) do={ :set newmonthnum 06 }
:if ([$month] = jul) do={ :set newmonthnum 07 }
:if ([$month] = aug) do={ :set newmonthnum 08 }
:if ([$month] = sep) do={ :set newmonthnum 09 }
:if ([$month] = oct) do={ :set newmonthnum 10 }
:if ([$month] = nov) do={ :set newmonthnum 11 }
:if ([$month] = dec) do={ :set newmonthnum 12 }

/tool user-manager user
:foreach i in=[ /tool user-manager user find customer=bren ] do={
:set disabled [get $i disabled]
:if ([$disabled] = false) do={
:set date [/system clock get date]
:set usrname [get $i name]
:set uptime [get $i uptime-used]
:set clientname [get $i first-name]
:set clientsurname [get $i last-name]
:set comment [get $i comment]
:set cap [:pick $comment 5 9]
:set warning [:pick $comment 9 11]
:if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 }
:if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 }
:set bytestotal ($bytesin + $bytesout)
:set gigstotal ($bytestotal / 1000000)
:set email [get $i email]
:if ([$total] = 0) do={ :set doespay “This is a Complimentary Account”} else={ :set doespay “-” }
/tool e-mail send to=$email password=xxxxxx server=“10.10.10.10” from=NoReply@volthan.co.za user=xx@xx.com subject=“[Usage info for user $usrname]” body="[info sent to $email

This is a statement for user account: $usrname
Your current total uptime is $uptime

Downloads: $bytesin
Uploads: $bytesout
Total: $bytestotal

Total Data Transferred: $gigstotal MB]"
:log info “Sent Invoice for $usrname to Accounting”
}
}




i get error to many simutaniousn smtp connections to server how can i delay it to 60 sec per email email sent?

can anyone tell me how to add a delay to send out 1 email every 5 sec

if i use :forevery i in???

Use delay.

/tool e-mail send ...
:delay 5;

tryed this but nothing

/tool e-mail send to=$email password=xxxxxx server=“xx.xx.xx.xx” from=NoReply@xx.co.za user=xx@xx.com subject=“[Usage info for user $usrname]” body="[info sent to $email


This is a statement for user account: $usrname
Your current total uptime is $uptime

Downloads: $bytesin
Uploads: $bytesout
Total: $bytestotal

Total Data Transferred: $gigstotal MB]"
:delay 00:00:15;
:log error “Sent Invoice for $usrname to Accounting”

Try something simple.

:foreach i in=$mylist do={
   /tool e-mail send to="me@mydomain.com" subject="email test" body="test $i"
   :delay 5;
}

Once you get the correct number of emails, then start modifying the script to include the rest of the data you want.

Got it all working thanks