Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#19280 - 10/22/02 07:40 AM Form to e-mail  
Joined: Sep 2002
Posts: 624
black^Pimp Offline
UGN GFX Whore
black^Pimp  Offline
UGN GFX Whore

Joined: Sep 2002
Posts: 624
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 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 04:24 PM Re: Form to e-mail  
Joined: Oct 2002
Posts: 37
ReverendNinjaSox Offline
Junior Member
ReverendNinjaSox  Offline
Junior Member

Joined: Oct 2002
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 05:12 PM Re: Form to e-mail  
Joined: Sep 2002
Posts: 624
black^Pimp Offline
UGN GFX Whore
black^Pimp  Offline
UGN GFX Whore

Joined: Sep 2002
Posts: 624
Underground
yeah Ninja, show me some of your stuff..
i desperately need to get this working !!


+^Born Intelligence
#19283 - 10/22/02 07:38 PM Re: Form to e-mail  
Joined: Oct 2002
Posts: 37
ReverendNinjaSox Offline
Junior Member
ReverendNinjaSox  Offline
Junior Member

Joined: Oct 2002
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.

#19284 - 10/22/02 08:19 PM Re: Form to e-mail  
Joined: Sep 2002
Posts: 624
black^Pimp Offline
UGN GFX Whore
black^Pimp  Offline
UGN GFX Whore

Joined: Sep 2002
Posts: 624
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
Sponsored Links

Member Spotlight
Gremelin
Gremelin
Portland, OR; USA
Posts: 7,195
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Forums45
Topics46,786
Posts81,956
Average Daily Posts11
Members2,159
Most Online1,567
Apr 25th, 2010
Latest Postings
Top Posters(All Time)
UGN Security 39,950
Gremelin 7,195
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
Ghost Likes: 1
Gremelin Likes: 4
Ice Likes: 1
unreal Likes: 1
Top Liked Users (30 Days)
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20160902)