skyler has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I found this script in this site and I'm trying to make it work. I installed the Mailer package including smtp.pm, mailer.pm, etc. By running this script I get an error message "Can't locate object method "open" via package "Mail::Mailer::smtp" I dodn't know what else to install does anyone have experience this issue. I'm trying to send an email from XP to a Nextel phone by using <phone#>@messaging.nextel.com. Does anyone have use a different package to acomplish this operation?? Here is the code
#! perl -w use Mail::Mailer; print "\nTo: "; $dest = <STDIN>; chomp $dest; print "Subject: "; $subj = <STDIN>; chomp $subj; print "\nBody:\n"; $body = <STDIN>; $mailer = Mail::Mailer->new("smtp", Server=> "smtpserver.edu"); $mailer->open( { From => 'john <sender@ser1.ser2.edu>', To => "$dest", Subject => "$subj" } ) or die "Couldnt do it: $!\n"; print $mailer $body; $mailer->close();

Replies are listed 'Best First'.
Re: Mail::Mailer question
by particle (Vicar) on Aug 15, 2003 at 17:50 UTC

    you should check that the mailer object exists. for example:

    $mailer= Mail::Mailer->new(...) or die qq{$0: Can't create mailer object: $!};

    you can further inspect the $mailer object with Data::Dumper

    use Data::Dumper; $Data::Dumper::Indent= 1; print Dumper $mailer;

    ~Particle *accelerates*

Re: Mail::Mailer question
by Mr. Muskrat (Canon) on Aug 15, 2003 at 17:49 UTC

    I like Mail::Sendmail.

    #!/usr/bin/perl -w use strict; use Mail::Sendmail; my %mail = ( from => 'john <sender@ser1.ser2.edu>', smtp => 'smtpserver.edu', ); print "To: "; chomp($mail{to} = <STDIN>); print "\nSubject: "; chomp($mail{subject} = <STDIN>); print "\nBody:\n"; $mail{message} = <STDIN>; sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log;