For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > MIME::Lite send_by_smtp cant change the default port









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MIME::Lite send_by_smtp cant change the default port
Ramprasad A Padmanabhan

2005-06-03, 3:56 pm

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
----------------------------------------------------------
Zentara

2005-06-04, 3:55 pm

On 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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com