Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 1st, 2000, 08:17 AM
ravi_kiruba ravi_kiruba is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 2 ravi_kiruba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just I need to know how the following code works.AS I am in the initial stage of learning Perl, I need your help for this.
I know that this code is for sending mail with the contnts taken from two text areas.
I need more expanation on it Please...


#!/usr/bin/perl

use CGI;
$query = new CGI;

$first_textarea_data = $query->param('textarea_a');
$second_textarea_data = $query->param('textarea_b');

$mailer = "/path/to/sendmail";

unless(open(MAIL, "|$mailer -t")) {
print "Unable to open sendmail at: $mailernn";
exit;
}

print MAIL "TO: recipient@some.comn";
print MAIL "SUBJECT: This is some fine mail!n";
print MAIL "FROM: you@your.comnn";

print MAIL $first_textarea_data;
print MAIL $second_textarea_data;

close(MAIL);


Reply With Quote
  #2  
Old November 1st, 2000, 12:00 PM
udd udd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 4 udd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to udd
I'm absolutly not a perl expert myself, but my the code means something like:

"#!/usr/bin/perl"
Specify where perl is located on your server

"use CGI;
$query = new CGI;

$first_textarea_data = $query->param('textarea_a');
$second_textarea_data = $query->param('textarea_b');"
The information that is posted from a HTML-page is transferd into variables. (the HTML-code should be something like:
<html>
<form action="blah.pl" method="post">
<textarea name="textarea_a"></textarea>
<textarea name="textarea_b"></textarea>
</form>
</html> )
The text entered in the textarea_a is saved into $first_textarea_data, and the text entered in textarea_b is saved into $second_textarea_data.

'$mailer = "/path/to/sendmail";'
Specify where sendmail is located on your server.

'unless(open(MAIL, "|$mailer -t")) {
print "Unable to open sendmail at: $mailernn";
exit;
}'

Open the mailer specified in $mailer (above) as MAIL.
If the opening fails a errormessage is viewed for the user.

'print MAIL "TO: recipient@some.comn";
print MAIL "SUBJECT: This is some fine mail!n";
print MAIL "FROM: you@your.comnn";'
Writes some thing into the mailer opened as MAIL.
This is the mails header (to, from, subject). After the header you need to n's.

"print MAIL $first_textarea_data;
print MAIL $second_textarea_data;"
Writes the content in the variables into the mailer (opened as MAIL).

"close(MAIL);"
Close the mailer.


As I wrote at the top of the message I'm not an expert, but I hope you know a little bit more. Otherwise I'm sure someoneelse here can tell you more about the script.

Reply With Quote
  #3  
Old November 9th, 2000, 10:59 AM
kfiras kfiras is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 kfiras User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This code simple takes the input from the user in two fields(textarea_a,text_area_b) in
an html form and emails and constructs the body of the email and then send it to the intended party.

At the begining, it checks to see if sendmail daemon is up and running on the box before trying to sewnd the email and if not, it prints out an error message saying so to the user.

Hope taht helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Need the explanation for this code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway