Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/classes/class_email.php
<?php
/**
 *@author José Augusto Ferreira Franco
 *@copyright Artistic Lisence
 *@link http://guto.awardspace.com
 *@package Class Email_Sender [main class]
 *@version 1.0 done at 12 Nov 2006 
 */

class email_sender
{
	
	var $msg;
	var $subject;
	var $from;
	var $to;
	
	
	
	function email_sender($account=array())
	{
		$this->from     = $account['from'];
		$this->subject  = $account['subject'];
		$this->msg      = $account['message'];
		
		
		
		if($this->is_email($account['to']))
		{
			$this->to = $account['to'];
			email_sender::send_email();
		}
		else
		{
			echo "<script>alert('Email incorrecto')</script>";
		}
	}
	
	function is_email($email)
	{
		//validação com expressões regulares
	if (ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$",$email) )
       return true;
     else 
       return false;
    }
    
    function boundary()
    {
    $bound = "__GutoEmailSender__".md5(uniqid(mt_rand(),true));	
    return $bound;
    }
    
    function headers()
    {
     $topHeader  = 'MIME-VERSION 1.0'.'\r\n';
     $topHeader .= 'Content-type: text/html; charset=iso-8859-1'.'\r\n';
     $topHeader .= 'From:'.$this->from.'\r\n';
     return $topHeader; 
    }
    
    function body()
    {
    $body  = $this->boundary().'\r\n';
    $body .= $this->msg;
    return $body;	
    }
    
    
    function send_email()
    {
     if(mail($this->to,$this->subject, $this->body(), $this->headers()))
     {
       echo "<script>alert('Email enviado com sucesso!')</script>"; 	
     }
    }
    
  
    
	
	
	
	
}

?>
Return current item: MyOWNSpace