473,756 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error in Net::SMTP Can't open server

63 New Member
Hi, I'm trying some code to send a mail with my script. This is it:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use Net::SMTP;
  3.  
  4. my $smtp_server='62.193.245.15';
  5. my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server\n";
  6. $smtp->mail('joao.correia@tvn.pt');
  7. $smtp->to('jcor@sapo.pt');
  8. $smtp->auth("joao.correia@tvn.pt","*password*");
  9. $smtp->data();
  10. $smtp->datasend("To: jcor@sapo.pt\n");
  11. $smtp->datasend("From: joao.correia@tvn.pt\n");
  12. $smtp->datasend("Subject: test\n");
  13. $smtp->datasend("\n");
  14. $smtp->datasend("some test text");
  15. $smtp->dataend();
  16.  
  17. $smtp->quit;
My problem is that it allways die when creating the object. It's not possible to create the objectwith the IP instead of smtp."something "?
Is this IP that I have in my thunderbird and it works perfectly!

Am I failing something?

Can someone give me an hand?

Thanks,

Joćo Correia
Jan 28 '08 #1
13 6809
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi, I'm trying some code to send a mail with my script. This is it:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use Net::SMTP;
  3.  
  4. my $smtp_server='62.193.245.15';
  5. my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server\n";
  6. $smtp->mail('joao.correia@tvn.pt');
  7. $smtp->to('jcor@sapo.pt');
  8. $smtp->auth("joao.correia@tvn.pt","*password*");
  9. $smtp->data();
  10. $smtp->datasend("To: jcor@sapo.pt\n");
  11. $smtp->datasend("From: joao.correia@tvn.pt\n");
  12. $smtp->datasend("Subject: test\n");
  13. $smtp->datasend("\n");
  14. $smtp->datasend("some test text");
  15. $smtp->dataend();
  16.  
  17. $smtp->quit;
My problem is that it allways die when creating the object. It's not possible to create the objectwith the IP instead of smtp."something "?
Is this IP that I have in my thunderbird and it works perfectly!

Am I failing something?

Can someone give me an hand?

Thanks,

Joćo Correia
How about this, change this line:

Expand|Select|Wrap|Line Numbers
  1. my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server\n";
  2.  
to be:

Expand|Select|Wrap|Line Numbers
  1. my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server: $!\n";
  2.  
and let us know what is printed out for the error after "Can't Open server". That will be the error that is being kicked back.

Regards,

Jeff
Jan 28 '08 #2
numberwhun
3,509 Recognized Expert Moderator Specialist
Just to let you know, when I telnet, it doesn't let me in:

>>telnet 62.193.245.15 25

Connecting To 62.193.245.15.. .Could not open connection to the host, on port 25:
Connect failed

If this holds true, I don't think it is accepting connections from outside. Is this an internal SMTP server for tvnet.pt?

Regards,

Jeff
Jan 28 '08 #3
jcor
63 New Member
It should retrieve in my console, right?
I got nothing, I run only this code:
Expand|Select|Wrap|Line Numbers
  1. use Net::SMTP;
  2. my $smtp_server='62.193.245.15';
  3. my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open server: $!\n";
  4. $smtp->quit;
  5.  
and this is my console:
Expand|Select|Wrap|Line Numbers
  1. joao@joao-UBUNTU:~/Desktop$ perl Net_SMTP 
  2. Can't Open server: 
  3. joao@joao-UBUNTU:~/Desktop$ 
Should I see the error in some filehandle, or something?
Jan 28 '08 #4
jcor
63 New Member
answering to your second post,I use that IP in my thunderbird smtp server and I send mails everywhere, I guess it's the correct smtp server.
Jan 28 '08 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
answering to your second post,I use that IP in my thunderbird smtp server and I send mails everywhere, I guess it's the correct smtp server.
You will have to bear with me as I don't have a ton of experience with this module, but from the documentation on CPAN, why not try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $smtp = Net::SMTP->new('mailhost',
  3.                            Hello => 'my.mail.domain',
  4.                            Timeout => 30,
  5.                            Debug   => 1,
  6.                           );
  7.  
If you read the link, you will see what each of the options does for you.

Regards,

Jeff
Jan 28 '08 #6
jcor
63 New Member
Hi, I decided to use other email account because maybe my smtp vould be with any problem, I don't know.
My code now is this:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use Net::SMTP;
  4.  
  5. my $smtp_server='smtp.mail.yahoo.com.br';
  6. my $smtp_to='joao_correia_0509@yahoo.com.br';
  7. my $smtp_auth='joao_correia_0509';
  8. my $smtp_pass='***password****';
  9. my $smtp_mail="yahoo";
  10.  
  11. my $smtp = Net::SMTP->new($smtp_server,
  12.               Timeout => 30,
  13.               Debug => 1,
  14.               ) or die "Can't Open server: $!\n";
  15. $smtp->auth($smtp_auth,$smtp_pass) or die "in auth: $!\n";
  16. $smtp->to($smtp_to) or die "in to: $!\n";
  17. $smtp->data();
  18. $smtp->datasend("test it ");
  19. $smtp->dataend();
  20. print $smtp->domain();
  21. print "it's gone!!!\n";
  22. $smtp->quit;
  23.  
Now it connects to the server but gives a error in the authorization. This is the output with the debug:

Expand|Select|Wrap|Line Numbers
  1. joao@joao-UBUNTU:~/Desktop$ perl Net_SMTP
  2. Net::SMTP>>> Net::SMTP(2.31)
  3. Net::SMTP>>>   Net::Cmd(2.29)
  4. Net::SMTP>>>     Exporter(5.58)
  5. Net::SMTP>>>   IO::Socket::INET(1.29)
  6. Net::SMTP>>>     IO::Socket(1.29)
  7. Net::SMTP>>>       IO::Handle(1.25)
  8. Net::SMTP=GLOB(0x82da17c)<<< 220 smtp108.mail.mud.yahoo.com ESMTP
  9. Net::SMTP=GLOB(0x82da17c)>>> EHLO localhost.localdomain
  10. Net::SMTP=GLOB(0x82da17c)<<< 250-smtp108.mail.mud.yahoo.com
  11. Net::SMTP=GLOB(0x82da17c)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE
  12. Net::SMTP=GLOB(0x82da17c)<<< 250-PIPELINING
  13. Net::SMTP=GLOB(0x82da17c)<<< 250 8BITMIME
  14. in auth: Ficheiro ou directoria inexistente
  15.  
The last line translation is "in auth: file or folder nonexistent", or something similar.

Can you help in this?

Or, in last case, can someone give me another module or something to send a mail from the script?

Thanks,

Joćo
thanks
Jan 29 '08 #7
eWish
971 Recognized Expert Contributor
I too have not messed with Net::Smtp, I prefer Mail::Sendmail or Mime::Lite. In addition to those, there are many modules for email on CPAN. Here is an excerpt from the Mail::Sendmail module.

Expand|Select|Wrap|Line Numbers
  1.   use Mail::Sendmail;
  2.  
  3.   %mail = ( To      => 'you@there.com',
  4.             From    => 'me@here.com',
  5.             Message => "This is a very short message"
  6.            );
  7.  
  8.   sendmail(%mail) or die $Mail::Sendmail::error;
  9.  
  10.   print "OK. Log says:\n", $Mail::Sendmail::log;
What OS are you using? Don't think that the authentication works correctly on a windows machine. If that is the case that you might look at Net::SMTP::TLS.

--Kevin
Jan 30 '08 #8
numberwhun
3,509 Recognized Expert Moderator Specialist
The only time I did play with this module, it was with a mail server that was internal and on the network that I was connected with. So, connecting and sending email was a breeze and it worked like a charm, I must say. Unfortunately, I haven't done anything with authentication, although I should. I would check the module(s) that Kevin suggested and see if any of them work for you.

Regards,

Jeff
Jan 30 '08 #9
jcor
63 New Member
I'm using Ubuntu 7.04

I'll take a look in the modules you told me.
But to use Mail::SendMail I'll have to configure "sendmail" in my ubuntu, right?
I'll try that

Thanks for your help,

Joćo
Jan 30 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3061
by: Almir | last post by:
I hate this Net::SMTP stuff, everything works fine but for the suject field. I see no way of having it show in an email when sent. Has anyone had this problem, can anyone explain why there are no documentations on smtp or better ones at least. I just need the subject field to show. $smtp = Net::SMTP->new('some.your.com'); $smtp->mail ($mailfrom); #the administrator's email goes here $smtp->to('mine@your.com');
2
13704
by: RandRace | last post by:
I'm having some problems with a little script i wrote using net::smtp. I originally wrote it in linux where it works perfectly. I tried to use it from windows the other day and it doesn't work. It connects to the server and prints the banner but will not send mail. Here is my script: use Net::SMTP; my $smtp = Net::SMTP->new('smtp.comcast.net') or die "Can't Open server"!";
0
1331
by: peterson | last post by:
I was trying to send asp.net-smtp mail of UTF-8 unicode international character contents. When I opened the mailbox contents was broken. I am using html format too. Am I missing something?
1
1823
by: neog | last post by:
I'm having a problem with Net::Smtp. Does the datasend() method have problems sending strings containing single quotes? Like I stored the string "Germany's biggest bank, hired" in a hash and it prints out fine when i retrieve the scalar value. But i do datasend($msg) and when i open the email I see something like "Germany's bigges! t bank, hired". These "!" are popping all over the place. Any thoughts would be greatly appreciated.
4
2371
by: patrickinminneapolis | last post by:
Hi guys, I'm trying to write an emailer, but I can't manage to construct the object properly. Here's what I've got: #!/usr/local/bin/perl -w use Net::SMTP; $smtp = Net::SMTP->new('mailhost'); print $smtp->domain,"\n"; $ perl mailer.txt Can't call method "domain" on an undefined value at mailer.txt line 6.
1
8497
by: =?Utf-8?B?V0o=?= | last post by:
Hi, I'm looking for a ASP.NET open source social network software to build a web-site. so far, I have no luck. If you have any information, can you help? Thanks. WJ
5
5301
by: jimhill10 | last post by:
I have a perl script that creates an email attachment file from POST data on a web page. This works just fine. I want to customize the email body to contain all of the text data from the file itself. I thought this would be just a matter of using the $smtp->datasend($POSTvalues) with the $values coming from the names on the web page posting the data. Can someone show me what the correct code snippet would be? Here is my code: ...
1
2695
by: wootmaster | last post by:
I'm writing a script that will run a few tests on a given mail server, it's meant to test to see if VRFY and EXPN is enabled or not. However, when I use "verify" to test to see if VRFY is enabled on the given host, if VRFY is disabled on the server the "verify" function will still return true/1. I used the Debug function to check, and it shows that VRFY is disabled on the mail server. Is there a reason or a way around this? snippet of...
5
7346
by: veralee | last post by:
I'm in dire need to use Net::SMTP. The server no longer uses "sendmail". I found an example of using Net::SMTP but I have to also include a user name and password for the server. The host provided that, and I discovered that the method call is, auth ( USERNAME, PASSWORD ). But I don't know where to put that call. The host isn't into Perl and I'm on my own about this. Could someone be so extremely kind as to show me a simple example of...
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.