kafkaf55 has asked for the wisdom of the Perl Monks concerning the following question:

I just installed Mail::Sendmail. Works fine. I am converting Korn Shell scripts to Perl. The way I did email was to write messages to a file and then send the email re-directing the file into email or "mail" on AIX.
I have looked around and cannot find a way of doing the same in Perl. I know there is a way.
Ken

Replies are listed 'Best First'.
Re: Mail::Sendmail multiline Message
by Corion (Patriarch) on Mar 17, 2010 at 12:49 UTC

    Without you showing us the (Perl) code, it's hard to tell. I have no problem sending multiline mails with Perl. Have you read Mail::Sendmail?

      Thanks again, Corion, you have been very helpful.

      use Mail::Sendmail;
      use vars qw(%mail) ;


      %mail = ( To => 'ifasftp@chesterfield.gov',
      From => 'burtonk@chesterfield.gov',
      Subject => 'Test email from Perl',
      Message => "< Many lines here"
      );

      sendmail(%mail) or die $Mail::Sendmail::error;

      I am looking at the "Message" item where I would like to enter many lines like a normal email.
      Ken

        So, what have you tried to put many lines into the parameter for Message? I ask, because the mechanisms that Perl supports are the same that the various shells, and certainly ksh support. Also see perlop on quotes and quote-like operators.

        Also, you could assign all the many lines to a variable and then use that variable as the value:

        my $message_text = "... many lines ..."; ... Message => $message_text, ...