in reply to Re^2: Mail::Sendmail multiline Message
in thread Mail::Sendmail multiline Message

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, ...

Replies are listed 'Best First'.
Re^4: Mail::Sendmail multiline Message
by kafkaf55 (Acolyte) on Mar 17, 2010 at 14:19 UTC
    I will review the perlop and let you know how things go.
    Ken
      This is how I'm sending the contents of a file via mail:

      ($HC is the file path to the file I'm going to send)
      open(MAIL, "|mail $EMAIL"); print MAIL "To: $EMAIL\n"; print MAIL "From: $mail_from\n"; print MAIL "Subject: $mail_sub\n"; print MAIL "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; open(MESSAGE, "<", "$HC") or die "$!"; print MAIL <MESSAGE>; close(MESSAGE); close(MAIL);

      Update: I should note that the reason I don't use Corion's method listed above is because the file was already created before sending, and it seemed silly to me to read it all into a variable to send the variable. If the performance hit of reading/writing from a disk was already made, didn't seem much of a benefit to add more logic into the operation.
        Thanks for jumping in sierpinski as I too already have a file that I want to use as input to email.
        This is different from the Mail:Sendmail description. Can you expand on what the open statement is doing?
        Does each print write an entry to the mail(setup?)?
        When do you actually send the mail?
        I assume the Content-Type is just saying to send regular text mail.
        Ken
Re^4: Mail::Sendmail multiline Message
by kafkaf55 (Acolyte) on Mar 18, 2010 at 15:26 UTC
    I need to expand on my messages. My program needs to write out messages at different times, thus why I write out to a file. When program is finished, I need to mail the results with all the information from the message file. I believe the here document will not work.
    Ken

      You could instead of appending to a file, append to a variable that holds the message. But then again, who am I to question your beliefs.

Re^4: Mail::Sendmail multiline Message
by kafkaf55 (Acolyte) on Mar 17, 2010 at 14:12 UTC
    In ksh, I am creating lines like:
    echo "This is line1" >> mail_content (file)
    echo "this is line2" >> mail_content

    Then, "mail ..subject.. ip address.. < mail_content"

    I am assuming same process in Perl??
    Ken

      That's not the process I would have used under ksh. I would build up a variable in ksh using a here-document or a string that spans multiple lines. The equivalent process to your echo approach would be to append the strings to a variable using the dot operator (.). Maybe you want to read perlop now?