Forgot Password / Register
Site Statistics
Total Members: 510
Total Tutorials: 242
Newsest User: Hp
Todays Unique Hits: 127
0 Users 1 Guests Online

PHP Mail

Its easy, and doesn't require and MYSQL databases. Well, lets get started.

First off, the form.

sendf.html:
Code

<form action='sende.php' method='post'>
Your name: <input type='text' name='name'><BR>
Subject: <input type='text' name='subject'><BR>
Email: <input type='text' name='email'><BR>
Message:<BR>
<textarea name='message'>Put your message here</textarea><BR>
<input type='submit' value='Submit'>
</form>


You can change the sizes of your boxes, thats up to you. Pritty much the above code just puts a form on your page, then once you click submit it sends it to your email which you can specify below.

sende.php:
Code

<?php
$name = $_POST['name']; // gets the users name
$subject = $_POST['subject']; //gets the subject
$message = $_POST['message']; // gets the message
$email = $_POST['email']; // gets the users email
$mail = "
Dear, Owner. You have a message from your site ($name). The subject line is: $subject. Below is the message: \r
$message \r
The message is from the email address of: $email."; // you can change this to whatever you want

if ( (!$subject)||(!$message) ) { // checks for the missing
echo "Please fix the following:<BR>";
if(!$subject) {
echo "Please fill in your subject<BR>"; // checks for subject
}
if(!$message) {
echo "Please fill in the message<BR><BR>"; // checks for message
}
echo "<form action='sende.php' method='post'>
Your name: <input type='text' name='name'><BR>
Subject: <input type='text' name='subject'><BR>
Email: <input type='text' name='email'><BR>
Message:<BR>
<textarea name='message'>Put your message here</textarea><BR>
<input type='submit' value='Submit'>
</form>";
} else {

mail("EMAILHERE@DOMAINHERE.com", "Subject: $subject", $mail, "From: $name <$email>");

if(mail) {
echo "Thank you please wait for a reply";
} else {
echo "Error: Message could not be sent";
}
}
// hope this helps
?>


I tested the code above and it works. I hope this helps you a lot.

Enjoy.

COMMING SOON: A WAY TO EMAIL YOUR USERS FROM A FORM :O.
Diablosblizz
Views:
1553
Rating:
Posted on Sunday 6th May 2007 at 04:56 PM
Diablosblizz
Diablosblizz
Don't understand?
Posted on Sunday 6th May 2007 at 01:28 PM
cyruswu
cyruswu
I wish there was once to view the email.