troubleshooting Question

Email through Perl

Avatar of meers1974
meers1974 asked on
4 Comments1 Solution438 ViewsLast Modified:
I am trying to send an email through perl and I get the following error message..Can someone help resolve this error.. Thanks.

Can't locate object method "new" via package "MIME::Lite" (perhaps you forgot to
 load "MIME::Lite"?) at line 23.

Here is the code:

# use MIME::Lite package
use MIME::Lite;

# set up email
$to = "";
$from = "";
$subject = "Email Sent via Perl";
$message = "This email was sent using Perl.";
$file = "c:\email.txt";

# send email
email($to, $from, $subject, $message, $file);

# email function
sub email
 # get incoming parameters
 local ($to, $from, $subject, $message, $file) = @_;

 # create a new message
 $msg = MIME::Lite->new(
  From => $from,
  To => $to,
  Subject => $subject,
  Data => $message

 # add the attachment
  Type => "text/plain",
  Path => $file,
  Filename => $file,
  Disposition => "attachment"

 # send the email
 MIME::Lite->send('smtp', '', Timeout => 60);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros