Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Error in MIME::Lite

by Anonymous Monk
on Jun 24, 2016 at 16:40 UTC ( [id://1166518]=perlquestion: print w/replies, xml ) Need Help??

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


I am getting below error, while trying mime::lite in my local.


'sendmail' is not recognized as an internal or external command, operable program or batch file.

The below is simple code :

#!C:\perl\bin\perl.exe -w use FindBin; use lib "$FindBin::Bin/.."; use lib "c:\\perl\\site\\lib"; use strict; use warnings; use MIME::Lite; my @body=('test'); my $to = ''; my $from = ''; my $subject = 'Test Email'; my $message = 'This is test email sent by Perl Script'; my $msg = MIME::Lite->new( From => $from, To => $to, Subject => $subject, Data => $message ); $msg->send();

any one help me in this?

Replies are listed 'Best First'.
Re: Error in MIME::Lite
by runrig (Abbot) on Jun 24, 2016 at 16:48 UTC
    Is sendmail installed? Maybe use smtp? See the docs.
      Is sendmail installed?

      Unlikely on Windows.

      Maybe use smtp?

      Yepp, that's the way MIME::Lite works on Windows. Recent versions should auto-detect a missing sendmail executable, IIRC.

      See the docs.

      Adding MIME::Lite->send("smtp", $mailserver); or MIME::Lite->send("smtp", $mailserver, AuthUser => $username, AuthPass => $password); before creating or using any MIME::Lite object should do the trick.


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Error in MIME::Lite
by Laurent_R (Canon) on Jun 24, 2016 at 20:30 UTC
    Please note the following caveat at the top of the Mime::Lite documentation:
    MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.
Re: Error in MIME::Lite
by Aldebaran (Curate) on Jun 26, 2016 at 05:27 UTC

    It might be true that there are 937 ways to send email in perl but more than half of those aren't maintained, because there are simply better, newer methods. I just went on an internet walkabout to figure out how to send email and was simply following cpan instructions to find better stuff and came up with this:

    use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTPS; use Try::Tiny; my $transport = Email::Sender::Transport::SMTPS->new( host => $host, ssl => 'starttls', sasl_username => $username, sasl_password => $password, debug => 0, # or 1 ); use Email::Simple::Creator; # or other Email:: my $message = Email::Simple->create( header => [ From => $username, To => $phone, Subject => 'Subject title', ], body => "Your link is $link\n", ); try { sendmail( $message, { transport => $transport } ); } catch { die "Error sending email: $_"; };

    This approach worked with a gmail account.I recommend this link

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1166518]
Approved by marto
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-05-24 08:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found