> -----Original Message-----
> From: Rice, Elizabeth A. [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 01, 2001 11:58 AM
> To: '[EMAIL PROTECTED]'
> Subject: Sending mail using PERL with file as body of message
> 
> 
> ...
> Here's the basic sendmail code:
> 
>         open(TMPMAIL, "<$tmpmail");
> 
>         use Mail::Sendmail;
> 
>         %mail = ( To      => "@slist",
>                   From    => '[EMAIL PROTECTED]',
>                   Subject => "$HOSTNAME $QMGR MQARCH03I Just 
> a short message
> ",
>                   Body    => <TMPMAIL>

This looks like a problem. <TMPMAIL> is being evaulated in a list context,
so it evaluates to a list containing one element for each line in the file.
But this list of lines is being used as a hash intializer (for %mail). So
the first line of the file becomes the value associated with the key 'Body'.
The second line of the file becomes another key in %mail, with the third
line of the file becoming the value associated with that key.

You need to have the entire body as one scalar. The use of <TMPMAIL> in the
hash initializer is too tricky for my blood. I would do something like this:

   open(TMPMAIL, "<$tmpmail") or die "Couldn't open: $!";
   my $body;
   {
      local $/ = undef;          # file "slurp" mode temporarily
      ($body) = <TMPMAIL>;
   }

Then use in the hash initializer:

   Body => $body

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to