TWiki::Net::sendEmail() takes the second argument as the number tries. If it's 5, 5 tries happen before the function gives up. But in the code, the term "retries" is used instead of tries, which is confusing. So switching from retries to tries in variable names and comments is desirable.
After a send failure, the function waits for retry. With the current implementation, the wait happens even after the last try, which is time waste.
After the number of tries, a message saying "Too many failures sending mail" is shown. This happens even if the number of tries is one. It doesn't sound right to call one failure "too many failures" though technically correct.