473,401 Members | 2,146 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,401 software developers and data experts.

send email through a perl script.

89
I am running a perl script under linux environment. I am looking for a possibility of sending mail to a set of pepole when something goes wrong. Is is possible to do? Thanks.
Aug 15 '08 #1
5 6906
lilly07
89
I found a small example as below and tried.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. my $to='xyz@hotmail.com';
  4. my $from='xyz@hotmail.com';
  5. my $subject='Low Disk Space';
  6.  
  7. # send email using UNIX/Linux sendmail
  8. open(MAIL, "|/usr/sbin/sendmail -t");
  9. my $out = "testing";
  10.  
  11.  
  12. ## Mail Header
  13. print MAIL "To: $to\\n";
  14. print MAIL "From: $from\\n";
  15. print MAIL "Subject: $subject\\n";
  16.  
  17. ## Mail Body
  18. print MAIL $out;
  19.  
  20. close(MAIL);

When I execute the code, I get a message as below:
Expand|Select|Wrap|Line Numbers
  1. No recipient addresses found in header
How to resolve? Can't I use any public domains like hotmail etc.. or do I have to set up anything in my linux server. Please let me know. Thanks.
Aug 15 '08 #2
KevinADC
4,059 Expert 2GB
You need to remove the extra backslashes in these lines:

Expand|Select|Wrap|Line Numbers
  1. print MAIL "To: $to\\n";
  2. print MAIL "From: $from\\n";
  3. print MAIL "Subject: $subject\\n";
  4.  
Should be:

Expand|Select|Wrap|Line Numbers
  1. print MAIL "To: $to\n";
  2. print MAIL "From: $from\n";
  3. print MAIL "Subject: $subject\n\n";
  4.  

Note the two \n\n after subject, that is necessary the way you are doing it.
Aug 15 '08 #3
numberwhun
3,509 Expert Mod 2GB
In addition to the example that you found, you can also check out the Net::SMTP module from CPAN. Its also a good way to go.

Regards,

Jeff
Aug 15 '08 #4
KevinADC
4,059 Expert 2GB
In addition to the example that you found, you can also check out the Net::SMTP module from CPAN. Its also a good way to go.

Regards,

Jeff
I think they got that suggestion on Devshed.
Aug 15 '08 #5
eWish
971 Expert 512MB
In this thread I posted some code that would send an email with out the use of additional modules.

--Kevin
Aug 17 '08 #6

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

Similar topics

4
by: julio Morales | last post by:
Hi! When a user is in a MSAccess form, with the values of a registry, and click on 'send this', I need to send the id. value of such registry to a perl script with visual basic. I can exec a...
9
by: Martin Foster | last post by:
Hi. I would like to be able to mimic the unix tool 'uniq' within a Perl script. I have a file with entries that look like this 4 10 21 37 58 83 111 145 184 226...
3
by: FLOTServer | last post by:
Here's my problem: I run a gameserver that runs the game "Medal of Honor". On the game server is log file which contains all of the data from the players for that day (kills, deaths, etc...). I...
6
by: von | last post by:
Is it possible to run a Perl script from within a javascript? I have an existing javascript that provides some data - and I want to write that data to a text file on my server via a Perl script...
1
by: mhawkins19 | last post by:
I have a form built and on the onclick event I validate all of the fields and then if the form is ok, on the submit event I run a javascript function to set a cookie and download a file from the...
1
by: Balajisanthanakrishnan | last post by:
Old Title: Hi all, need help for this perl script- thanks in advance I am BalajiSanthanakrishnan, chennai. Now I am working in a Perl Script which is executing in the Unix Servers. Basically i am...
1
by: rahulthathoo | last post by:
Hi, After i finish some amount of computation using a perl script, i need to send out an email to a receipient which can change and is known to the Perl script. Is there a way to call the...
2
by: dandaman2007 | last post by:
Hi All, I need some expertise Perl help..... Basically i have an Email perl script that i use on alot of my sites, which basically E-mails the filled in form to a specified e-mail address....
1
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir...
3
by: vijayarl | last post by:
Hi all, i have perl script, which is used to send mail. its a command line utility. if we run this perl script in command line by passing all it's required arguments, it works very well.there no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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,...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.