Created a main function. Code partialy adapted to Python conventions
Improved SMTP exception treatment