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

by karger (Initiate)
 on Jul 26, 2013 at 19:03 UTC 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(); [download] HELP! Replies are listed 'Best First'. Re: Can't locate objet method "new" via package "Mail::SendMail" by Perlbotics (Chancellor) 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();
[download]
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 chromatic (Archbishop) on Jul 26, 2013 at 20:48 UTC
$obj = new Mail::SendMail();$obj = new SendMail($smtpserver);$obj = new SendMail($smtpserver,$smtpport);
[download]

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 (Canon) 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);
[download]

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. Re: Can't locate objet method "new" via package "Mail::SendMail" by PerlSufi (Friar) 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;
[download]
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?

Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046588]
Approved by toolic
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-19 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (114 votes). Check out past polls.

Notices?