Are you sure that start-tls parameter for e-mail send command exists on your ROS version? There is tls parameter which accepts yes, no or starttls values - E-mail - RouterOS - MikroTik Documentation
Write in terminal /tool e-mail send and press Tab key on keyboard to see available parameters. If there is tls printed then replace in your command start-tls=$UseTLS with tls=starttls (or use variable).
If this is not tls argument issue, could be character escaping issue in $PasswordMail variable for password value, for eg. if contains $ character. See Scripting - RouterOS - MikroTik Documentation
My first guess, you haven't add app password to use gmail smtp.
You trying to use your regular username and password.
Here a link to YT Video how to setup app password. https://youtu.be/y5IasMFYdBc
well I feel somehow stupid.. The script is ok, I used it the terminal and the email was sent succesfully. The problem was the wrong password in the Tools/Email…
Thanks all of you for your help!**
**