Reputation: 35
This is my code so far:
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Lite;
my $to = '[email protected]';
my $from = '[email protected]';
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->add( "Type" => "multipart/mixed" );
$msg->send("smtp", "good.domain.net");
print "Email Sent Successfully\n";
When i want to run the script i got the following error:
Failed to connect to mail server: Bad file descriptor at ...\email.pl line 17.
I have no idea what the problem could be. Has someone any idea how to fix this?
EDIT: I corrected the code above, it is working with the proper server (it does not require authentication at all).
Upvotes: 0
Views: 2220
Reputation: 10903
Try to narrow search for your problem.
1: Do you get SMTP greeting message when you telnet the SMTP host?
telnet mail.domain.net 25
1:YES => add debug option to MIME::Lite send (via SMTP) call.
$msg->send("smtp", "mail.domain.net", Debug=>1, AuthUser=>'[email protected]', AuthPass=>"password" );
Upvotes: 1