Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Can't locate objet method "new" via package "Mail::SendMail"

by karger (Initiate)
on Jul 26, 2013 at 19:03 UTC ( #1046588=perlquestion: print w/ replies, xml ) Need Help??
karger has asked for the wisdom of the Perl Monks concerning the following question:

Hi this is driving me nuts. I just installed perl. I went into the perl package and installed sendmail. Now when I try and run my test script i get: Can't locate object method "new" via package "Mail::SendMail" (perhaps you forgo t to load "Mail::SendMail"?) at C:\Temp\sendmail.pl line 14. Here is my code:
#!/usr/local/bin/perl use Mail::SendMail; $smtpserver = "mail.karger.net"; $smtpport = 25; $sender = 'Karger <karger@karger.com>'; $subject = "OMG NO"; $recipient = '<karger@karger.com>'; $replyto = $sender; $header = "X-Mailer"; $headervalue = "Perl SendMail Module 1.09"; $obj = new Mail::SendMail(); $obj = new SendMail($smtpserver); $obj = new SendMail($smtpserver, $smtpport); $obj->From($sender); $obj->Subject($subject); $obj->To($recipient); $obj->ReplyTo($replyto); $obj->setMailHeader($header, $headervalue); if ($obj->sendMail() != 0) { print $obj->{'error'}."\n"; } $obj->reset();
HELP!

Comment on Can't locate objet method "new" via package "Mail::SendMail"
Download Code
Re: Can't locate objet method "new" via package "Mail::SendMail"
by Corion (Pope) on Jul 26, 2013 at 19:06 UTC

    YOu are on a case insensitive filesystem and misspelled Mail::SendMail. The module name is Mail::Sendmail with a lowercase m.

Re: Can't locate objet method "new" via package "Mail::SendMail"
by Perlbotics (Abbot) on Jul 26, 2013 at 19:15 UTC
      So i changed my use log line to say use Mail::Sendmail; I still seem to get the same error though on this line:
      $obj = new Mail::Sendmail();
Re: Can't locate objet method "new" via package "Mail::SendMail"
by PerlSufi (Pilgrim) on Jul 26, 2013 at 19:33 UTC
    Hi there,
    I just sent posted this example block of code on another node, but I ended up using MIME::Lite to send email through smtp. In this example I sent a tar file
    my $mail = MIME::Lite->new( From=> 'me@me.com, To=> 'someone@cool.com', Subject=> "Hello email ", Type=>'multipart/mixed' ); $mail->attach( Type => 'application/x-tar', Encoding => 'base64', Path => 'C:\path\to\file.tar', Filename => "file.tar" ); MIME::Lite->send('smtp','server.smtp.com',Debug=>0); $mail->send;
    I am aware that one of the first lines of documentation for this module the author discourages using MIME::Lite. I have also used MIME::Entity in its place. Hope this helps..
      thanks. Perhaps i need a proper exmaple of a send mail. Anyone?
Re: Can't locate objet method "new" via package "Mail::SendMail"
by chromatic (Archbishop) on Jul 26, 2013 at 20:48 UTC
    $obj = new Mail::SendMail(); $obj = new SendMail($smtpserver); $obj = new SendMail($smtpserver, $smtpport);

    Where did you get that example code? What do you expect it to do?


    Improve your skills with Modern Perl: the free book.

Re: Can't locate objet method "new" via package "Mail::SendMail"
by hippo (Curate) on Jul 26, 2013 at 22:21 UTC
    I went into the perl package and installed sendmail.

    You'll have to explain what you mean by that, because it makes no sense to me.

    $obj = new Mail::SendMail(); $obj = new SendMail($smtpserver); $obj = new SendMail($smtpserver, $smtpport);

    So, you overwrite $obj three times in three lines? I think it might be best if you were to explain a bit more what it is that you expect your script to do. You might think about using strict too.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046588]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-08-29 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (277 votes), past polls