At 4:47 AM -0500 2/9/01, Scott R. Godin wrote:
>-------
>#!/usr/bin/perl -w
>
>use strict;
>use Mail::Mailer qw(smtp);
Get rid of this ^^^^^^^
>
>my $smtp = new Mail::Mailer 'smtp', 'Server' => 'mail.magpage.com';
>my %headers = (
> "To" => '[EMAIL PROTECTED]',
> "From" => '[EMAIL PROTECTED]',
> "Subject" => "This is a test :-)",
>);
>
>my $body = <<"EOF";
>This is a cheap-ass test of the mailer system
>
>should this work, rejoice!
>
>EOF
>
>$smtp->open(\%headers) or die $!;
>
>print $smtp $body;
>
>$smtp->close or die $!;
>
>exit 0;
>---------
>
>results in
># Use of uninitialized value.
>File '(snipped path):site_perl:Mail:Mailer.pm'; Line 210
># Use of uninitialized value.
>File '(snipped path):site_perl:Mail:Mailer.pm'; Line 189
># Cannot locate ''
>File 'Dev:Pseudo'; Line 4
># Bad file descriptor.
>File 'Primus 8.5GB:Web Pages:cgi-scripts:ncrp:testing:mailertest.plx'; Line
>24
The complaints come from the fact that you told it what type to use,
and it tried to see if you had an executable named "smtp" on your
Unix system. On Mac OS, if you don't give it a type, it
automatically uses "smtp". This is a bug in Mail::Mailer.
The last complaint (bad file descriptor) is from your $smtp->close
line. Just don't use it. $smtp isn't a file descriptor here. This
is also a bug, I suppose.
>
>If I change the headers to To: From: and Subject: it just says "died" as an
>error. (wtf?)
>
>The above, as written, 'works' (mysteriously I recieve an e-mail anyway),
>but I have NO idea why it barks at me so much.
>
>The documentation in this thing is REALLY sparse, and the way that it
>'checks' for a suitable mail binary under MacOS is really specious to say
>the least, IMHO, after looking at the code.. I've gone OUT of my way to
>specify that it use an SMTP format, so why does the module STILL Search for
>a mail binary (parTICULARLY under MacOS) even though I've TOLD it what I
>want to use?
>
>Any suggestions?
>
>The documentation in Mail::Mailer is so sparse as to be almost useless for
>someone not using nor 100% familiar with a unix environment, i.e. me :)
>
>
>I really don't get it. *scratching head*
>
>(this script at least *works* without barking at me, even though it doesn't
>produce RFC822 compliant headers):
>-------
>#!perl -w
>use strict;
>use Net::SMTP;
>
>my($smtp, $email, $to, $subject, $message);
>
>$smtp = Net::SMTP->new('mail.magpage.com') or die "$!";
>$email = '"Scott R. Godin" <[EMAIL PROTECTED]>';
>$to = '"Scott R. Godin" <[EMAIL PROTECTED]>';
>$subject = "Subject: testing MacPerl SMTP access";
>$message = <<EOM;
>
>
>Perl sent this message. Nifty, eh? :-)
>
>Just another Perl Hacker hard at work. =]
>
>EOM
>
>$smtp->mail($email) or die("$!");
>$smtp->to($to) or die("$!");
>$smtp->data() or die("$!");
>$smtp->datasend($subject) or die("$!");
>$smtp->datasend($message) or die("$!");
>$smtp->dataend() or die("$!");
>$smtp->quit() or die("$!");
>
>-------
>
>Perhaps a little more explanation of what 'headers' are allowable would be
>in order, as well as a more thorough 'working script example' of 'how it
>should be done' for a simple script such as this should be added to the pod
>documentation.. particularly for us new folks..
>
>There's also no real "tie it all together" pod file that explains when and
>where you would want to use each of the separate modules in Mailtools, and
>THAT was sorely sorely missed. :-/
>
>...
>
>Some other things I tried as I was typing this were simply to remove the
>qw(smtp) and the whole 'smtp', Server => 'mail.magpage.com' from the script
>and let Mail::Mailer figure things out from my config files and Internet
>settings, but that produced NO results and the script doesn't even die with
>an error!
>
>NOR does it work if I leave off qw(smtp) from the use statement and simply
>do
>
> my $smtp = new Mail::Mailer 'smtp', 'Server' => 'mail.magpage.com';
>
>(again no die, no error)
>
>Why no error? that makes NO sense to me.. it should at least report the
>error or die or SOMETHING other than a no-op. :)
>
>From what the docs indicate, it should 'fall-through' mail and sendmail and
>wind up at smtp automatically if no forced $type is given. and if it reaches
>(i.e. falls-through to) 'test' and there's no /bin/echo why
>shouldn't/couldn't/doesn't it simply print to STDOUT ?
>
>Confused,
>
>--
>Scott R. Godin | e-mail : [EMAIL PROTECTED]
>Laughing Dragon Services | web : http://www.webdragon.net/
--
--
Paul Schinder
[EMAIL PROTECTED]