Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 316
0 Users 2 Guests Online

PHP Mail Part 2

Well, im back, I already coded the first bit of PHP Mail, so go check it out before reading this.

This time, ill make a code that will automatically form a email so you don't have to write it out each and every time! Lets get started:

sendo.html:
Code

<form action="sendo.php" method="post">
To: <input type="text" name="email"><BR> <!-- Put email of user there -->
From: <input type="text" name="emailfrom"><BR> <!-- Put email of you, or your name. -->
Subject: <input type="text" name="subject"> <!-- Put the subject here --><BR>
Message:<BR><textarea name="message">Put your message here</textarea><BR>
<input type="submit" value="Submit">
</form>


Easy enough right? Sure? Now for the PHP which will send it!

sendo.php:
PHP Code
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
32
33
34
35
<?php
$to 
$_POST['email'];
$from $_POST['emailfrom'];
$subject $_POST['subject'];
$message $_POST['message'];
$mess "You have received a message from YOURSITEHERE. The subject line was: $subject. \r
$message \r
The message was sent from the email/name of: 
$from.";

if ( (!
$to)||(!$subject)||(!$message) ) {
echo 
"Please fix the following:<BR>";
if(!
$to) {
echo 
"Please enter the email to who you are sending the message to<BR>"; }
if(!
$subject) {
echo 
"Please fill in a subject!<BR>"; }
if(!
$message) {
echo 
"What are you planning to send?<BR><BR>"; }
echo 
"<form action='ie.php' method='post'>
To: <input type='text' name='email'><BR> <!-- Put email of user there -->
From: <input type='text' name='emailfrom'><BR> <!-- Put email of you, or your name. -->
Subject: <input type='text' name='subject'> <!-- Put the subject here --><BR>
Message:<BR><textarea name='message'>Put your message here</textarea><BR>
<input type='submit' value='Submit'>
</form>"
;
} else {
mail("$to""Subject: $subject"$mess"From: $from");

if(
mail) {
echo 
"Your message was sent";
} else {
echo 
"Sorry, there was a error sending the message";
}
}
?>


**Note: I noticed if your using a spam controll (Spam Assassin), the message will not go threw, but it works with Gmail, hotmail, and any Hosting without Spam Assassin.

Another Easy Tutorial, end of the series. Hope you like.
Diablosblizz
Views:
2072
Rating:
There are currently no comments for this tutorial.