<?php 

    
// ////////////////////////////////////////////////////////
    // DISCLAIMER / LICENSE AGREEMENT v1.0
    //
    // This script is developed by Digitalus Webhosting & 
    // Webdesign and can be used by people who would like 
    // to host a simple contact form on their website. 
    // The script is nothing more than a tool which is designed
    // to do nothing more than that. 
    // Digitalus Webhosting & Webdesign can not give any 
    // support on the script nor help out to get the script
    // working.
    // Digitalus Webhosting & Webdesign can not be held 
    // resonsible for any problems or damage which are caused 
    // by usage of the scripts.
    // Use the scripts at your own risk.
    // Digitalus Webhosting & Webdesign has the right to change
    // this disclaimer without any notifications.
    // ////////////////////////////////////////////////////////

    
class email
    
{        
        public  
$meldingen '';
        private 
$intern_gereserveerd = array("intern_onderwerp","melding_verzonden""verplichte_velden""melding_verplichte_velden");
        private 
$elementen '';

        
// GET INFO
        
public function get_post ($get_post)
        {
            
$this->elementen $get_post;
        }
        
        
// MAKE EMAIL HEADERS
        
private function maak_headers ()
        {            
           
$this->headers  "MIME-Version: 1.0\r\n"
           
$this->headers .= "From: " $this->ontvanger "\n"
           
$this->headers .= "To: " $this->ontvanger "\n"
           
$this->headers .= "Reply-To: " $this->ontvanger "\n";
           
$this->headers .= "X-Priority: 3\n"
           
$this->headers .= "X-Mailer: Digitalus Webhosting & Webdesign - Mailscript 1.0\n"
        }
        
        
// CREATE CONTENT OF THE MESSAGE
        
private function maak_inhoud ()
        {
            foreach (
$this->elementen as $key => $value)
            {
                if(!
in_array($key,$this->intern_gereserveerd))
                    
$this->bericht .= ucfirst($key) . ":\n" strip_tags($value) . "\n\n";    
            }            
        }
        
        
// CHECK THE REQUIRED FIELDS
        
public function controleer_verplichte_velden ()
        {
            
$verplicht explode(',',$this->elementen['verplichte_velden']);
            
            foreach (
$this->elementen as $key => $value)
            {
                if(
in_array($key,$verplicht) && empty($value))
                    
$this->meldingen .= preg_replace('/\[VERPLICHT\_VELD\]/',$key,$this->elementen['melding_verplichte_velden']) . '<br />';
            }        
        }
        
        
// SEND MESSAGE
        
public function verstuur_bericht ()
        {
            
// CHECK REQUIRED FIELDS
            
$this->controleer_verplichte_velden();
            
            
// SHOW ERROR MESSAGE IF PRESENT
            
if(!empty($this->meldingen))
                echo 
$this->meldingen;
            else            
            {
                
// EMAIL HEADERS
                
$this->maak_headers();
                
                
// LOOP THOUGH THE $_POST VALUES
                
$this->maak_inhoud();            
                
                
// SEND THE E-MAIL
                
if(!mail($this->ontvanger,$this->elementen['intern_onderwerp'],$this->bericht,$this->headers))
                    echo 
'Fout: er is iets mis gegaan bij het verzenden van de e-mail.';
                else 
                    echo 
$this->elementen['melding_verzonden'];
            }    
        }        
    }

?>