Code Comments
Programming Forum and web based access to our favorite programming groups.Hi ALL,
I am trying to send a mail using MIME::Lite
I am trying to connect to port 26 of smtp server instead of 25 , but no
luck
I am not able to see anything wrong in this script , I hope I could get
some inputs
Thanks
Ram
------------------ My script is here
#!/usr/bin/perl
use strict;
use MIME::Lite;
my $str= <<EOHTML;
This is a test mail
Please ignore
EOHTML
my $msg = MIME::Lite->new(
To => $ARGV[0],
From => $ARGV[1],
Subject => 'Test Mail',
Type => 'multipart/related'
);
$msg->attach( Type => 'text/plain', Data => $str );
$msg->send_by_smtp("192.168.2.65",Port=>26);
-----------------------
This is the output I get
Failed to connect to mail server: Bad file descriptor
at perl/smtp26 line 17
----------------------------------------------------------
Netcore Solutions Pvt. Ltd.
Website: http://www.netcore.co.in
Spamtraps: http://cleanmail.netcore.co.in/directory.html
----------------------------------------------------------
Post Follow-up to this messageOn Fri, 03 Jun 2005 15:55:10 +0530, rampra@netcore.co.in (Rampra
A Padmanabhan) wrote: >Hi ALL, > > I am trying to send a mail using MIME::Lite > I am trying to connect to port 26 of smtp server instead of 25 , but no >luck >I am not able to see anything wrong in this script , I hope I could get >some inputs >------------------ My script is here >#!/usr/bin/perl >use strict; >use MIME::Lite; > >my $str= <<EOHTML; >This is a test mail >Please ignore >EOHTML >my $msg = MIME::Lite->new( > To => $ARGV[0], > From => $ARGV[1], > Subject => 'Test Mail', > Type => 'multipart/related' > ); > >$msg->attach( Type => 'text/plain', Data => $str ); >$msg->send_by_smtp("192.168.2.65",Port=>26); > > >----------------------- >This is the output I get > >Failed to connect to mail server: Bad file descriptor >at perl/smtp26 line 17 I have this example working, using MIME::Lite and Net::SMTP, but it dosn't use MIME::Lite's send_by_smtp; it uses Net::SMTP to do the sending, and gets the $msg->as_string from MIME::Lite. Also make sure there is something listening on port 26. Usually when the server is on a non-standard port, you need auth too. So you may need the Net::SMTP_auth module. #!/usr/bin/perl use warnings; use strict; use MIME::Lite; use Net::SMTP; my $Servername = "mail.foobar.net"; my $Port = 26; my $msg = MIME::Lite->new( From => 'me@foobar.net', TO => 'you@feefifo.net', Subject => 'Testing Text Message ', Data => 'How's it going. Sent with Net-SMTP and MIME::Lite' ); #get MIME::Lite's message #my $msgbody = $msg->as_string(); my $smtp = Net::SMTP->new($Servername, Port=>$Port ); $smtp->mail('me@foobar.net'); $smtp->to('you@feefifo.net'); $smtp -> data(); $smtp -> datasend( $msg->as_string() ); $smtp -> dataend(); $smtp -> quit; __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.