UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
Sponsored Links
Latest Postings
by Gremelin
10/05/15 06:01 PM
Latest Reviews
Topic Options
Rate This Topic
#19280 - 10/22/02 12:40 AM Form to e-mail
black^Pimp Offline

Registered: 09/26/02
Posts: 624
Loc: Underground
Hi guys

Listen, i need a PHP Form to e-mail script, do you guys have any script like that in PHP or other langauges maybe, but i want a good one ok.
I'm giving out a free 5 mb e-mail accout for my site , so i wanna make an Email Registration page probably, so i need something like the UGN Security Admin Application and all the submissions will be sent to my email.

I want a PHP script possiable, you guys have any suggestions or anything ?
+^Born Intelligence

Sponsored Links
#19281 - 10/22/02 09:24 AM Re: Form to e-mail
ReverendNinjaSox Offline
Junior Member

Registered: 10/03/02
Posts: 37
You said other languages. I do this all the time using Perl. I use CGI, strict, Apache::Constants qw(:common), and the most important one. Net::SMTP. Net::SMTP makes it really simple. A brain dead chipmunk on crack could figure out Net::SMTP in under half an hour. If you are on a *NIX system just type man Net::SMTP. It'll give you more information then you ever wanted. If you want examples of them though, I suppose I could show you some of the stuff I've done.

#19282 - 10/22/02 10:12 AM Re: Form to e-mail
black^Pimp Offline

Registered: 09/26/02
Posts: 624
Loc: Underground
yeah Ninja, show me some of your stuff..
i desperately need to get this working !!
+^Born Intelligence

#19283 - 10/22/02 12:38 PM Re: Form to e-mail
ReverendNinjaSox Offline
Junior Member

Registered: 10/03/02
Posts: 37
Ok. This is done in mod_perl. First you need to set up the appropriate mod_perl entry in your httpd.conf file. Mine looks a bit like this.

<IfModule mod_perl.c>

  PerlModule Apache::DBI
  PerlSetVar mailhost

    use Utils;
    use CGI;

  <Location /mailer>
    SetHandler perl-script
    PerlHandler MailFormHandler
You don't have to do that step if you don't want to. I'll explain a bit on how to avoid it shortly though. Ok lets see. The next thing you are going to need is the CGI. This is a short version of what my CGI looks like.

package MailFormHandler;

$| = 1;

use strict;    #using strict.  I never code without it.
use CGI;       #I use CGI so I can automatically parse forms.
use Apache::Constants qw(:common);  #Because it's sexy.
use Net::SMTP;  #Do I really have to explain?

sub handler() {  # This handler is required for using mod_perl.

    my $obj = new CGI; # Defining my CGI.

    my $mailhost = "";  #The Mail Host
    my $recipient = $obj->param("recipient"); # Who is getting the email?
    my $subject = $obj->param("subject"); #The subject of the email.  If the email doesn't have a subject entered, set the default to MailFormHandler email
    if (!$subject) {
        $subject = "MailFormHandler email";
    my $sender = "[email protected]"; #Do I have to explain everything to you now?
    my $returnpage = $obj->param("returnpage"); #The return page is the page you are going to want the person to go to after they have submitted the form.  You can make them go to any page you want.  The information is kept in the form.  We will get to that.

    my $emailaddress = $obj->param("email"); # The persons email address that they entered into the form.
    my $smtp = new Net::SMTP($mailhost); #Activating the SMTP module.
    $smtp->mail($sender); #Setting the sender.
    $smtp->to($recipient); #Setting the recipient
    $smtp->data(); #Specifying that we want to start putting in some data.  Next three lines are self-explanatory.
    $smtp->datasend("To: " . $recipient . "\n");
    $smtp->datasend("From: " . $sender . "\n");
    $smtp->datasend("Subject: " . $subject . "\n\n");
#This next block is going to run through all the parameters that were in the field and put them in the email.
    my ($name, $val);
    foreach $name ($obj->param()) {
        if (($name !~ /\.x$/) and ($name !~ /\.y$/)) {
            foreach $val ($obj->param($name)) {
                $smtp->datasend($name . ": " . $obj->param($name) . "\n");

    print $obj->redirect($returnpage);

    return OK;


Ok. Now for a quick look at what the form will look like.

<form action="/mailer">
<input type=hidden name="recipient" value="Who Is Getting The Email">
<input type=hidden name="returnpage" value=/page/to/return/to>

<input type=hidden name="subject" value="Website Feedback">
Your Name
<input name="Name" size=40>

Your Address
<input name="address" size=40>

<input name="address2" size=40>

Your Phone Number
<input name="telephone" size=40>

Your Email
<input name="email" size=40>

<textarea rows=10 cols=40 name=Comments></textarea>

<input type=submit value="Send Comments">

If you need any more explanations on it. Feel free to let me know.

#19284 - 10/22/02 01:19 PM Re: Form to e-mail
black^Pimp Offline

Registered: 09/26/02
Posts: 624
Loc: Underground
Ninja thanks a lot for trying to help me out, but i just think i'm not understanding this pretty good since i don't know Perl. But you know what ? I'll email you and we'll talk through mails ok.

Thanks for your help man i appreciate it.

+^Born Intelligence


Moderator:  §intå×, Gremelin 
Featured Member
Registered: 03/02/02
Posts: 137
Forum Stats
2158 Members
46 Forums
41550 Topics
76725 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 34712
Gremelin 7194
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Jan Havelles, Herbert_Sherbert, codemauve, Lillysdragon1984, Brewwit
2158 Registered Users
Who's Online
0 registered (), 293 Guests and 385 Spiders online.
Key: Admin, Global Mod, Mod
Latest News

  Get Firefox!
Get FireFox!