On Wed, Feb 20, 2002 at 08:58:41AM -0800, Bhanu Prakash wrote:
> when a user submits a form, the input  entered by him should be
> mailed to the address he specifies in one of teh input fileds.!  

If you put that one on a public webserver, you should consider a way
to prevent bad people from using it as spam relay.

> can anybody give me some bare bone structure of how I should
> accomplish this?

For example, you could use Net::SMTP 

#!/usr/bin/perl -w
#
# sendmail.pl - httpd -> smtp gateway
#
#####################################################################
use CGI;
use Net::SMTP;

# defines
$from    ="httpd\@jfranken.de";
$mailhost="localhost";

# Get CGI- query params
$q      =new CGI;
$subject=$q->param("subject");
$text   =$q->param("text");
$to     =$q->param("to");
die unless ($subject and $text and $to);

# SMTP (RFC 821) -Header
$smtp = Net::SMTP->new($mailhost) or die;
$smtp->mail($from) or die;
$smtp->to($to) or die;

# Mail (RFC822) -Header
$smtp->data() or die;
$smtp->datasend("From: $from\n") or die;
$smtp->datasend("To: $to\n") or die;
$smtp->datasend("Subject: $subject\n") or die;

# Mail (RFC822) -Body
$smtp->datasend("\n$text\n") or die;
$smtp->dataend() or die;
$smtp->quit or die;

# HTML Feedback to the user
print "Content-Type: text/html\n\n<html><body bgcolor=\"#ffffff\">Your message was 
sent<p><a href=\"" . $ENV{HTTP_REFERER} . "\">continue</A></body></html>";

exit

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to