Lose ends

While I have explained the two biggest part of the script, I haven’t actually told about the part I’ve used the most: the function log().

While print() does work (especially for such a simple script), is it still nice to have a file. And one does not exclude the other. I have more or less the same logic for a simple log function written in the languages I use the most (C++, Python, Bash and even PowerShell (for work - I swear!)).

I have been thinking about expanding them a bit. Adding log levels etc. I might write about that some day.

Another part that deserves mentioning, is one that I can’t take any credit for. The one that checks for connection. The code comes from a comment at Stack Overflow, made by miraculixx. It check for connection in two ways; one by looking up a hostname/uri, then by creating a connection to it at a specific port. Perfect for checking connection to a imap server.

This is a good solution because it check the specific server that I want to use, without requiring it to answer to ICMP (pings).

And of cause, it closes the connection at the end.

Round up

Well. That was the first project to hit these pages. In two ways even. The complete code can be found here.

After I’ve written this, I’m honestly not sure why I wanted to publish poems to this site. So that might change. I will hopefully remember to update the links in this series I move them.

Another thing to keep in mind, is the security aspect. While it is possible to spoof the from address in a mail, the spam filter on the mail provider I’m using is quite good at catching spoofed addresses. there probably could be other checks in this code as well. Or even some encryption and a key to unlock it. it might be a good exercise some day. But I’m taking my chances for now.

Thank you for stopping by, and I hope you could use some of my experiences.