Refactored getmail to reduce indentation (previously had 7 levels of indentation!)