Logged In: NO

I found that my IMAP server would add CRs before LFs which
made some rules work badly. Could be just my rules, but try it:

$Message =~ s/\015\012/\012/g;

Add this just after "my $Message = ..."