$__to =~ s/(\r\n|\n\r|\r|\n)/\r\n/sg; $__cc =~ s/(\r\n|\n\r|\r|\n)/\r\n/sg; ... #### my %mail = ( "To" => "$__to", "Subject" => "$__subject", "Content-Type" => $__content_type, ); #### for ( $__to, $__subject, $__content_type, ... ) { tr/\r\n/ /; s/\s+$//; } my %mail = ( "To" => $__to, "Subject" => $__subject, "Content-Type" => $__content_type, ); #### my @message_lines = ( '', # blank line 'This is a multi-part message in MIME format.', '','', # a couple blank lines "------=$_random_boundary", ..., # i.e. one array element for every line of message content '','' # including a couple blanks at the end ); my $_mail_message = join( "\r\n", @message_lines );