Okay, I was fuming mad. I have been struggling with a program that is
supposed to send a simple e-mail...
or so I thought!

for 2 days I have sent test e-mails all of them with headers in the e-mail
and attachments all screwy.
then I found the culprit.

at the top of my script is:

local $\ = "\n";

now ... isn't local supposed to "modify the listed variables to be local to
the enclosing block, file, or eval." ?

then why when I set this variable just before some code (Mail::Sender or
MIME::Entity) that builds the e-mail and sends it, that the e-mail ALWAYS
comes out wrong (wrong == improper formatting, wrong headers, bad multipart,
etc.).

below I have attached some sample code for both modules with the local $\ =
"\n" [untested sample code but should be 95% correct since I just change
some private items to garbage]...

Am I just misunderstanding the use of local?????????????????

Thank you for any explaination to this behavior,

Nikola Janceski

The average person thinks he isn't. 
-- Father Larry Lorenzoni 


use MIME::Entity;

local $\ = "\n";

my $top = MIME::Entity->build(
                                Type    => "multipart/mixed",
                                From    => "nikola_janceski\@summithq.com",
                                To      => '[EMAIL PROTECTED]',
                                Subject => "something"
                                );
$top->attach(Data=>"duh duh duh");
my $file = "/usr/nj/somefile";
if(-f $file){
        $top->attach(
                Path            => $file,
                Type            => "text/plain",
                Encoding        => "base64");
}

open MAIL, "| /usr/lib/sendmail -t -oi -oem -f 'klehman\@summithq.com'" or
die "open: $!";
    $top->print(\*MAIL); ## this is a method call which shouldn't be touched
by the local $\ right?
    close MAIL;


#### similar problems when using Mail::Sender;
use Mail::Sender;

local $\ = "\n";

my $sender;
ref($sender = new Mail::Sender
  {smtp => 'mail.localhost.com'}) || die "new $sender --
$Mail::Sender::Error\n";

ref($sender->OpenMultipart({from => $from.'@summithq.com', to =>
'[EMAIL PROTECTED]',
                       subject => $subject}) ) || die "OpenMultipart
$Mail::Sender::Error\n";

$sender->Body();
$sender->Send("duh duh duh");

my $file = "/usr/nj/somefile";
if( -f $file ){
        $sender->SendFile({
                ctype => 'text/plain',
                encoding => 'base64',
                file => "$file"
                }) || die "$Mail::Sender::Error\n";
}

$sender->Close() || die "$Mail::Sender::Error\n";

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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

Reply via email to