Email Form On My Webpage Using Dreamweaver Query

Associate
Joined
6 Feb 2004
Posts
270
Location
Ballymena
I have created an Email form on my webpage, with First Name, Surname, Email Address, Subject and Comments. i am using mailto: in the actions box which opens up Outlook or Outlook Express when someone goes to use the form. What i would like to happen here is for the email to be sent directly from my page without loading it into the persons email program and then redirecting them to a webpage saying Thankyou your email has been sent successfully. Can someone talk me through how this is done?

Many Thanks in Advance
 
Associate
Joined
2 Dec 2004
Posts
138
Location
oxford
Not sure if you can do that without an E-mail system on the web server. I know ive tried before but im not that skilled. I can create a email form in aspx but it requires an exchange server for sending it.

Sorry not much help :mad:

iceman911
 
Soldato
Joined
18 Oct 2002
Posts
5,159
Location
Riding my bike
iceman911 is right you will need to host the form on a server that can provide cgi facilities like perl or PHP these all have libraries that will allow v.easy email facilities.
 
Associate
Joined
9 Oct 2006
Posts
1,945
Location
Location Location!
PHP has a mail function.

http://uk.php.net/manual/en/function.mail.php

PHP:
$to  = '[email protected]';
$subject = $_POST['subject'];
$message = $_POST['comments'];
$headers = 'From: ' . $_POST['firstname'] . " " . $_POST['surname'] . "\r\n" .
    'Reply-To: ' . $_POST['email'] . "\r\n" .
    'X-Mailer: A PHP Script';

mail($to, $subject, $message, $headers);

It would probobly... No definitely worth putting in IP logging and a spam protection filter on that.
 
Last edited:
Associate
Joined
7 Jun 2005
Posts
108
Instead of having a mailto: link, you instead have a form, method=get, action=your_php_page.php

Then in your php page:
Code:
<?
$recip = $_GET["txtRecip"];
$subject = $_GET["txtSubject"];
$body = $_GET["txtBody"];

mail($recip, $subject, $body, $headers, "From: someemail.com");  

echo "<html><head><title>Thanks</title></head>";
echo "<body> <H1> Thanks for the email! </h1> </body> </html>";

?>

Obvously you need to filter the user content.. remove invalid and sploitable characters, add some spam control etc. But that's the basis of a simple mail form. Note those txtBody txtRecip etc all need to tally with the actual field names on your form.
So your form needs to be like
input type="text" name="txtRecip"

Then you have a submit button to click on, rather than a mailto link
 
Back
Top Bottom