473,287 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Net::SMTP simple constructor problem

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.



I thought at first that I didn't have the Net::SMTP library, so I tried use Net::SMTP222; which broke, since Net::SMTP doesn't break I assume I have the file in the right place, its here:
/usr/lib/perl5/5.8/Net/SMTP.pm

Thanks
Patrick
Jul 5 '07 #1
4 2336
KevinADC
4,059 Expert 2GB
change "mailhost" to the name of your actual smtp server. Generally something like:

mail.yourwebsite.com
Jul 5 '07 #2
change "mailhost" to the name of your actual smtp server. Generally something like: mail.yourwebsite.com

I tried smtp.gmail.com, smtp.wisc.edu, and smtp.hotmail.com, but none of these work. Do I need an SMTP server running on localhost? Thanks for your help.
Patrick
Jul 5 '07 #3
KevinADC
4,059 Expert 2GB
No you do not need a local smtp server running. You just need a connetion to the internet. Maybe someone else will have a suggestion, I don't know why the new constructor is not returning a value.
Jul 5 '07 #4
miller
1,089 Expert 1GB
Read the detailed documentation concerning the constructor of an Net::SMTP object.

cpan Net::SMTP

Also, always add an "or die" statement to your new object constructor. It will often tell you exactly what the problem is and you won't have to ask here.

Expand|Select|Wrap|Line Numbers
  1. my $smtp = Net::SMTP->new($MAIL_SERVER,
  2.     Hello    => 'who.are.you.com',
  3. ) or die "Failed to connect to mail server: $!";
  4.  
Finally, you probably shouldn't be using Net::SMTP anyway. Instead use MIME::Lite

cpan MIME::Lite

- Miller
Jul 5 '07 #5

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

Similar topics

0
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...
2
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...
0
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?
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
1
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...
13
by: jcor | last post by:
Hi, I'm trying some code to send a mail with my script. This is it: #!/usr/bin/perl use Net::SMTP; my $smtp_server='62.193.245.15'; my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open...
5
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...
1
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...
5
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.