I have checked the above code by executing it, it is executing successfully but I am not getting any mail notification for the failure or DOWN URLs.
And please try to use "CURL -i URL" so that will get the error response and store it in file and send as attachment in a mail.
Now it is creating NotOKURLs.txt file for the URL which is not live, but along with that if we use attachment as error logs from CURL command.
Hoping for your quick response, please check why it is not sending the mails, I have set the smtp,sender and recipient properly.