Zend - The PHP Company




Email

Add Code


Zonemail  

Type: application
Added by: zignal
Entered: 18/12/2003
Last modified: 02/11/2002
Rating: - (fewer than 3 votes)
Views: 5792
A simple email application with verification. Tested.


<?php
header
("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// --- ZONEMAIL 1.1 
// --- programmed with PHP4 and bluefish webeditor for LINUX 
// --- copyright: zignal@zignalzone.com 
// #################----------><----------#######################
// This script requires your server to have a SMTP server present
// in the PHP.INI file. If you dont know this, contact your ISP 
// #################----------><----------####################### 
if ($beensubmitted)  //check if form variables are set 
    
{
        
$subject htmlspecialchars($subject);  // kills all html tags in subject field
        
$body htmlspecialchars($body);        // kills all html tags in body field 
        //---------------------------------------------------------------------------
        
if (($subject == "") or ($body == ""))  //simple error check to see if vars are empty 
                
{
                    echo 
'<h5>Subject box or body were left empty, please try again</h5>';
                    echo 
'<a href="javascript:history.go(-1)">Go back to Email form</a>';
                    exit;
                }
        
//---------------------------------------------------------------------------        
        //---------------------------------------------------------------------------    
        
if(mail('you@example.com'$subject$body))  //Change the address to your own email
                
{
                    echo 
'Succsessfully sent the email:<br><b>';
                    echo 
$subject;
                    echo 
'</b><br>';
                    echo 
'<a href="http://www.example.com">Go back</a>';  //change to your domain 
                
}
        else
                {
                    echo 
'<h5>sendmail server is down at the moment, please try later</h5>';
                    echo 
'<a href="http://www.example.com">Go back</a>'//your domain 
                
}
         
//---------------------------------------------------------------------------        
    
}
    else
    {
                    
// displays the mail form 
                    
echo '<form method="post" action="'.$PHP_SELF.'">';
                    echo 
'<center>';
                    echo 
'<b>Email subject:</b><br />';
                    echo 
'<input type="text" name="subject" size="30"><br /><br />';
                    echo 
'<b>Email body:</b><br />';
                    echo 
'<textarea name="body" rows="20" cols="50"></textarea><br />';
                    echo 
'<input type="submit" value="Send" name="beensubmitted">';
                    echo 
'&nbsp;&nbsp;<input type="reset" value="Reset">';
                    echo 
'</center>';
                    echo 
'</form>';
    }
// ---------------------------------------------------------------------------------
//Hope you like it    
?>


Usage Example




Rate This Script





Search



This Category All Categories