http://www.perlmonks.org?node_id=1205213


in reply to Losing eol character using MIME::Lite

Hi

Who's eating the eol? At this point I'm willing to blame the dog, but if anybody could point me toward a more likely suspect, I would greatly appreciate it. As would the dog.

Start with Basic debugging checklist

Also don't write your program in between subroutine declarations

As you can see no newlines are missing

#!/usr/bin/perl -- use strict; use warnings; use MIME::Lite; use Data::Dump qw/ dd /; my $source_heart_beat_timestamp = ''; my $target_heart_beat_timestamp = ''; $source_heart_beat_timestamp = "foo"; $target_heart_beat_timestamp = "bar"; my $output_msg = "Source Heart Beat TimeStamp: " . $source_heart_beat_timestamp . "\n +"; $output_msg .= "Target Heart Beat TimeStamp: $target_heart_beat_timest +amp"; local_do_mail("local_do_mail:\n$output_msg"); $source_heart_beat_timestamp = "20171207_113255"; $target_heart_beat_timestamp = "bar"; $output_msg = "Source Heart Beat TimeStamp: " . $source_heart_beat_timestamp . "\n +"; $output_msg .= "Target Heart Beat TimeStamp: $target_heart_beat_timest +amp"; local_do_mail("local_do_mail:\n$output_msg"); exit 0; sub local_do_mail { my ($msg_body) = @_; my $msg = MIME::Lite->new( From => 'cloudops@example.com', To => 'cbeckley@example.com', Subject => 'testing missing eol', Data => $msg_body ); #~ $msg->send; #~ $msg->print; dd( $msg->as_string ); } __END__ "Content-Disposition: inline\nContent-Transfer-Encoding: 8bit\nContent +-Type: text/plain\nMIME-Version: 1.0\nX-Mailer: MIME::Lite 3.029 (F2. +84; T2.04; A2.12; B3.14; Q3.13)\nDate: Fri, 8 Dec 2017 19:41:07 -0800 +\nFrom: cloudops\@example.com\nTo: cbeckley\@example.com\nSubject: te +sting missing eol\n\nlocal_do_mail:\nSource Heart Beat TimeStamp: foo +\nTarget Heart Beat TimeStamp: bar" "Content-Disposition: inline\nContent-Transfer-Encoding: 8bit\nContent +-Type: text/plain\nMIME-Version: 1.0\nX-Mailer: MIME::Lite 3.029 (F2. +84; T2.04; A2.12; B3.14; Q3.13)\nDate: Fri, 8 Dec 2017 19:41:07 -0800 +\nFrom: cloudops\@example.com\nTo: cbeckley\@example.com\nSubject: te +sting missing eol\n\nlocal_do_mail:\nSource Heart Beat TimeStamp: 201 +71207_113255\nTarget Heart Beat TimeStamp: bar"

Count the \n there are 2 in both messages

"local_do_mail:\nSource Heart Beat TimeStamp: foo\nTarget Heart Beat T +imeStamp: bar" "local_do_mail:\nSource Heart Beat TimeStamp: 20171207_113255\nTarget +Heart Beat TimeStamp: bar"

So who is to blame? The destination displaying the email body.

Replies are listed 'Best First'.
Re^2: Losing eol character using MIME::Lite
by cbeckley (Curate) on Dec 09, 2017 at 14:29 UTC

    Thand you for this:  use Data::Dump qw/ dd /;
    I didn't know about dd.

    You and Marto are correct, the problem is in the destination.
    That had not occurred to me; I thought I was missing some nuance of MIME or string syntax.

    Thank you.

    Thanks,
    cbeckley