Thanks for the tip about the code tags, I ignorantly used
[code][/code] to start with and it didn't work so I pastbined it here to avoid cluttering the front page. Good call on the readmore tags though, it made me realize the tag syntax I was using was the problem, I should have investigated it further.
Anyway, I shorted it down to the part of concern, there probably isn't much that can be improved to the smtp email sending and logging so I took it out from the example. Thanks for the comments so far, I'll make some reflected changes tomorrow and report back with an update.