View Single Post
12-13-2006, 11:31 AM
#13
sparckyz is offline sparckyz
sparckyz's Avatar
Status: Member
Join date: Nov 2006
Location: Nowhere
Expertise:
Software:
 
Posts: 192
iTrader: 0 / 0%
 

sparckyz is on a distinguished road

  Old

I got another one here if anyone's interested.
PHP Code:
<?php

/*
    Written by sparckyz
*/

//get variables
if($_POST['from'] && $_POST['sub'] && $_POST['mess'])
{

    
//your e-mail address
    
$To="some@address.com";

    
//check recipients e-mail address is formatted correctly
    
if(!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$",$To))
        die(
"please enter a valid 'to' address.");

    
//check senders e-mail address is formatted correctly
    
if(!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$",$_POST['from']))
        die(
"please enter a valid 'from' address");

    
//simplify variables
    
$From=$_POST['from'];
    
$Subject=$_POST['sub'];
    
$Message=$_POST['mess'];

    
//mail the message
    
$Mail=mail($To,$Subject,$Message,"from: $From");

    
//check if message was sent
    
if($Mail)
    {
        echo 
"message sent successfully.";
    }
    else
    {
        echo 
"unable to deliver message.";
    }

}

?>


<!-- html form -->
<form name="mail" method="post" action="<?=$php_self ?>">

    from:<br> <input type="text" name="from"><br>
    subject:<br> <input type="text" name="sub"><br>
    message:<br> <textarea name="mess" wrap="virtual" cols="30" rows="4"></textarea><br>

    <input name="mail" type="submit" value="mail">

</form>
I wrote it a few days ago out of boredom, so might as well post it