[boulder.pm] Help printing to e-mail

Walter Pienciak walter at frii.com
Mon Jan 24 17:01:24 CST 2000


Hi, Wayde,

I don't do format anymore.  Not for a long time, and I understood
it only poorly then.  That said, I *do* do a lot of system-generated
e-mails.  It all looks more or less like this:

my $SENDMAIL = "/usr/lib/sendmail -t";

# I stick this in a "config" section near the top, along with a bunch
# of stuff like
#    my $ADMIN = 'w.pienciak at ieee.org';
# which all pays off handsomely when people/things start changing.
# Even "sendmail", when we moved to postfix, needed to have the switches
# twiddled.

open( SENDMAIL, "| $SENDMAIL" ) or die "No sendmail?! : $!";
print SENDMAIL <<"EOT";
From: $ADMIN
To: $ADMIN
Cc:
Subject: $subject

EOT

# Now can print some funky stuff:

if ($doc_url ne "") {
    print SENDMAIL qq{and the <a href="$doc_url">draft being balloted</a>};
}

print SENDMAIL <<"EOT";

and so on.
EOT

close SENDMAIL;

I'm guessing that if you get the headers out of your format stuff,
things will go better.

Hope that helps,
Walter



On Mon, 24 Jan 2000, Wayde Allen wrote:

> 
> OK, I'm stumped.  I've been trying to build a web based purchase
> requisition system and everything is basically in place.  Unfortunately
> I'm having difficulty creating a nicely formated e-mail.
> 
> I've been able to create a decent message using something like:
> 
>    format MAIL =
>    From:  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>           $sender
>    To:    @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
>           $recipient
>    Subject:  Request for Purchase Approval
>    .
> 
>    open (MAIL, "|/usr/lib/sendmail -oi -t") or die "<P>Can't Fork Sendmail</P>: $!";
>    write MAIL;
> 
> This works, but I need to create a variable length formated table, and
> don't see how to do this with a static format.  
> 
> So, resorting to brute force I have tried creating the format on the fly. 
> The idea is to create a row for each item being ordered.  The problem I'm
> having is that now I'm getting an error saying "No recipient addresses
> found in header".  The code looks like: 
> 
>    my $formated_txt = "format MAIL = \n"
>    . "From: \@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< \n"
>    .        $sender . "\n"
>    . "To: \@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< \n"
>    .      $recipient . "\n"
>    . "Subject:  Request for Purchase Approval\n"
>    . ".\n";
> 
>    eval $formated_txt;
> 
>    open (MAIL, "|/usr/lib/sendmail -oi -t") or die "<P>Can't Fork Sendmail</P>: $!";
>    write MAIL;
> 
> Anyone see what I'm doing wrong, or have a better solution?
>  
> - Wayde
>   (wallen at boulder.nist.gov)
> 
> 




More information about the Boulder-pm mailing list