Yes, that’s exactly what happened. The script is ok, I’ve used it many times. When I used the script to send an email to let’s say "email@example.com" the email arrived within 5 seconds. When I used it to send an email to "firstname.lastname@example.org" or "email@example.com" the message didn’t arrive. And I also checked the spam folders.
But, when I checked after about 5-6 hours later, all the emails arrived on all the addresses and they all were in the INBOX folder.
So, I guess it’s a problem with the mail server. Probably some strange delay because I still can’t explain why on yahoo.co.uk the emails were sent immediattly and on other domains it took hours.