Imap send

This is a cleanup of my imap_mail patch, 

it attempts to fix the following bug 
https://bugs.php.net/bug.php?id=30688