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
July
Su M Tu W Th F Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Sponsored Links
Latest Postings
Latest Reviews
Topic Options
Rate This Topic
#19280 - 10/22/02 08:40 AM Form to e-mail
black^Pimp Offline
UGN GFX Whore

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 http://www.snogy.com , so i wanna make an Email Registration page http://www.snogy.com/email.php 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

Top
Sponsored Links
      
#19281 - 10/22/02 05:24 PM 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.

Top
#19282 - 10/22/02 06:12 PM Re: Form to e-mail
black^Pimp Offline
UGN GFX Whore

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

Top
#19283 - 10/22/02 08: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.

Code:
<IfModule mod_perl.c>

  PerlModule Apache::DBI
  PerlSetVar mailhost 10.100.100.23

  <Perl>
    use Utils;
    use CGI;
    CGI->compile(':all');
  </Perl>

  <Location /mailer>
    SetHandler perl-script
    PerlHandler MailFormHandler
  </Location>
</IfModule>
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.

Code:
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 = "funeralplan.com";  #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");
            }
        }
    }
    $smtp->dataend();
    $smtp->quit;

    print $obj->redirect($returnpage);

    return OK;

}

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

Code:
<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>

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

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

</form>
If you need any more explanations on it. Feel free to let me know.

Top
#19284 - 10/22/02 09:19 PM Re: Form to e-mail
black^Pimp Offline
UGN GFX Whore

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.

bp
_________________________
+^Born Intelligence

Top

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 03/05/02
Posts: 9
Forum Stats
2145 Members
46 Forums
33395 Topics
68562 Posts

Max Online: 1567 @ 04/25/10 10:20 AM
Top Posters
UGN Security 26558
Gremelin 7192
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Jimmie Menon, fghijk435948, Devo60, ali, lavos
2147 Registered Users
Who's Online
0 registered (), 643 Guests and 336 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!