Source for file module_mail.class.php

Documentation is available at module_mail.class.php

  1. <?php   /*
  2.    *@=@=@=@ START LICENSE @=@=@=@*
  3.    Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
  4.    
  5.    stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
  6.    
  7.    This software is a computer program whose purpose is to make a
  8.    web hosting platform
  9.    
  10.    This software is governed by the CeCILL  license under French law and
  11.    abiding by the rules of distribution of free software.  You can  use, 
  12.    modify and/ or redistribute the software under the terms of the CeCILL
  13.    license as circulated by CEA, CNRS and INRIA at the following URL
  14.    "http://www.cecill.info". 
  15.    
  16.    As a counterpart to the access to the source code and  rights to copy,
  17.    modify and redistribute granted by the license, users are provided only
  18.    with a limited warranty  and the software's author,  the holder of the
  19.    economic rights,  and the successive licensors  have only  limited
  20.    liability. 
  21.    
  22.    In this respect, the user's attention is drawn to the risks associated
  23.    with loading,  using,  modifying and/or developing or reproducing the
  24.    software by the user in light of its specific status of free software,
  25.    that may mean  that it is complicated to manipulate,  and  that  also
  26.    therefore means  that it is reserved for developers  and  experienced
  27.    professionals having in-depth computer knowledge. Users are therefore
  28.    encouraged to load and test the software's suitability as regards their
  29.    requirements in conditions enabling the security of their systems and/or 
  30.    data to be ensured and,  more generally, to use and operate it in the 
  31.    same conditions as regards security. 
  32.    
  33.    The fact that you are presently reading this means that you have had
  34.    knowledge of the CeCILL license and that you accept its terms.
  35.    *@=@=@=@ END   LICENSE @=@=@=@*
  36.  
  37. */?><?php  
  38. /**
  39.  * ModuleMail Class
  40.  * 
  41.  * 
  42.  * @author SimpliciWeb
  43.  * @version $Id: module_mail.class.php 606 2007-07-19 10:14:30Z stephanet $
  44.  * @package Common
  45.  * @subpackage FrameWork
  46.  */    
  47. /**
  48.  * Require xPliciMail.class.php
  49.  */
  50. require_once('xPliciMail.class.php');
  51.  
  52. /**
  53.  * The module send mail to use
  54.  *
  55.  * @author SimpliciWeb
  56.  * @version $Id: module_mail.class.php 606 2007-07-19 10:14:30Z stephanet $
  57.  * @package Common
  58.  * @subpackage FrameWork
  59.  */
  60.     class ModuleMail extends xPliciMail  {
  61.     
  62.         
  63.         /**
  64.          * Constructor, init the requests and objects
  65.          *
  66.          * @return ModuleMail 
  67.          */
  68.         function ModuleMail({
  69.             parent::xPliciMail();
  70.         }
  71.         
  72.  
  73.         /**
  74.          * send a email to $p_to from $p_header's email
  75.          * $p_html set the email in html
  76.          *
  77.          * @param string $p_to 
  78.          * @param string $p_subject 
  79.          * @param string $p_body 
  80.          * @param string $p_header 
  81.          * @param string $p_html 
  82.          * @return bool 
  83.          */
  84.         function send($p_to$p_subject$p_body$p_header$p_body_type{
  85.  
  86.             // Header can have this form:
  87.             //    -nicolas.s@simpliciweb.net
  88.             //    -From: nicolas.s@simpliciweb.net
  89.             //    -From: "Simpliciweb - Nicolas" <nicolas.s@simpliciweb.net>
  90.             //    -From: "Ma Communauté" <nicolas.s@simpliciweb.net>
  91.             //     Return-Path: nicolas.s@simpliciweb.net
  92.             //     Date: Thu, 13 Jul 2006 09:27:54 +0000
  93.             //     Content-Type: text/plain; charset=ISO-8859-15!!
  94.  
  95.             // Set name for email
  96.             $email_name '';
  97.             // set email
  98.             $email_email '';
  99.             // Select name and email from complete headers
  100.             $p_headers explode("\n",trim($p_header));
  101.                 // Select only From's line
  102.             $from_line = isset($p_headers[0])?$p_headers[0]:'';
  103.                 // Delete "From:"
  104.             if (== strncasecmp("FROM:"$from_line5))
  105.             {
  106.                 $from_line trim(substr($from_line5));
  107.             }
  108.             $names array();
  109.                 // Detect name
  110.             $nb_result preg_match('@"([^"]*)"@is',$from_line$names);
  111.             if (0<$nb_result)
  112.             {
  113.                 $email_name $names[1];
  114.                 $from_line trim(str_replace('"'.$names[1].'"'''$from_line));
  115.                 // Delete '<' '>' aroud the email
  116.                 if('<' == $from_line[0])
  117.                 {
  118.                     $from_line trim(substr($from_line1-1));
  119.                 }
  120.             }
  121.             // Set email
  122.             $email_email $from_line;
  123.             
  124.             $this->setFromName($email_name);
  125.             $this->setFromEmail($email_email);
  126.             $this->m_subject_prefix = "";
  127.             $this->setSubject($p_subject);
  128.             $this->setRecipients($p_to);
  129.             $this->setBodyType($p_body_type)// Set body type
  130.  
  131.             return $this->xSend($p_body);
  132.         
  133.         }
  134.         
  135.     
  136.     }
  137.  
  138. ?>

Documentation generated on Tue, 25 Mar 2008 15:35:19 +0100 by phpDocumentor 1.3.2