http://www.perlmonks.org?node_id=751871

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

I am getting
SMTP Failed to connect to mail server: Bad file descriptor
when running the following code on Windows
use MIME::Lite; my $msg=MIME::Lite->new(From=>"xx", To=>'xxx@xxx.com', Subject=>'Test MIME', Data=>"This is the test message"); $msg->send;
What am I missing?
  • Comment on MIME::Lite returns "SMTP Failed to connect to mail server: Bad file descriptor"
  • Download Code

Replies are listed 'Best First'.
Re: MIME::Lite returns "SMTP Failed to connect to mail server: Bad file descriptor"
by olus (Curate) on Mar 19, 2009 at 23:23 UTC

    Maybe two things. Not having sendmail installed and not having read the module's full documentation.

    If you have a server that can send mails for you, there is the send_by_smtp method to which you can specify that server's name.

    my $mailer = 'hostname'; $msg->send_by_smtp($mailer); # do some error checking
      /* Not having sendmail installed */

      how to check/install sendmail?
      and I guess I am not using it or I am mistaken?

        I recommend the second approach first, simply reading and understanding the module documentation. It explains the module defaults and what to do on Windows.

Re: MIME::Lite returns "SMTP Failed to connect to mail server: Bad file descriptor"
by Anonymous Monk on Mar 19, 2009 at 22:13 UTC
    sendmail, or a hostname.
      Could you please clarify.
Re: MIME::Lite returns "SMTP Failed to connect to mail server: Bad file descriptor"
by Anonymous Monk on Apr 28, 2009 at 10:22 UTC
    Try turning debug on with: MIME::Lite->send('smtp','host.com',Debug=>1);