XOOPS Docs - class
[ class tree: class ] [ index: class ] [ all elements ]

Source for file xoopsmultimailer.php

Documentation is available at xoopsmultimailer.php

  1. <?php
  2. // $Id: xoopsmultimailer.php 1061 2007-09-28 14:39:33Z phppp $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27. // Author: Jochen Büînagel (job@buennagel.com)                               //
  28. // URL:  http://www.xoops.org                                                 //
  29. // Project: The XOOPS Project                                                //
  30. // ------------------------------------------------------------------------- //
  31. if (!defined("XOOPS_ROOT_PATH")) {
  32.     die("XOOPS root path not defined");
  33. }
  34. /**
  35.  * @package        class
  36.  * @subpackage    mail
  37.  * 
  38.  * @filesource
  39.  *
  40.  * @author        Jochen Büînagel    <jb@buennagel.com>
  41.  * @copyright    copyright (c) 2000-2003 The XOOPS Project (http://www.xoops.org)
  42.  *
  43.  * @version        $Revision: 1061 $ - $Date: 2007-09-28 10:39:33 -0400 (Fri, 28 Sep 2007) $
  44.  */
  45.  
  46. /**
  47.  * load the base class
  48.  */
  49. require_once(XOOPS_ROOT_PATH.'/class/mail/phpmailer/class.phpmailer.php');
  50.  
  51. /**
  52.  * Mailer Class.
  53.  * 
  54.  * At the moment, this does nothing but send email through PHP's "mail()" function,
  55.  * but it has the abiltiy to do much more.
  56.  * 
  57.  * If you have problems sending mail with "mail()", you can edit the member variables
  58.  * to suit your setting. Later this will be possible through the admin panel.
  59.  *
  60.  * @todo        Make a page in the admin panel for setting mailer preferences.
  61.  * 
  62.  * @package        class
  63.  * @subpackage    mail
  64.  *
  65.  * @author        Jochen Buennagel    <job@buennagel.com>
  66.  * @copyright    (c) 2000-2003 The Xoops Project - www.xoops.org
  67.  * @version        $Revision: 1061 $ - changed by $Author$ on $Date: 2007-09-28 10:39:33 -0400 (Fri, 28 Sep 2007) $
  68.  */
  69. class XoopsMultiMailer extends PHPMailer {
  70.  
  71.     /**
  72.      * "from" address
  73.      * @var     string 
  74.      * @access    private
  75.      */
  76.     var $From         = "";
  77.     
  78.     /**
  79.      * "from" name
  80.      * @var     string 
  81.      * @access    private
  82.      */
  83.     var $FromName     = "";
  84.  
  85.     // can be "smtp", "sendmail", or "mail"
  86.     /**
  87.      * Method to be used when sending the mail.
  88.      * 
  89.      * This can be:
  90.      * <li>mail (standard PHP function "mail()") (default)
  91.      * <li>smtp    (send through any SMTP server, SMTPAuth is supported.
  92.      * You must set {@link $Host}, for SMTPAuth also {@link $SMTPAuth},
  93.      * {@link $Username}, and {@link $Password}.)
  94.      * <li>sendmail (manually set the path to your sendmail program
  95.      * to something different than "mail()" uses in {@link $Sendmail})
  96.      * 
  97.      * @var     string 
  98.      * @access    private
  99.      */
  100.     var $Mailer        = "mail";
  101.  
  102.     /**
  103.      * set if $Mailer is "sendmail"
  104.      * 
  105.      * Only used if {@link $Mailer} is set to "sendmail".
  106.      * Contains the full path to your sendmail program or replacement.
  107.      * @var     string 
  108.      * @access    private
  109.      */
  110.     var $Sendmail = "/usr/sbin/sendmail";
  111.  
  112.     /**
  113.      * SMTP Host.
  114.      * 
  115.      * Only used if {@link $Mailer} is set to "smtp"
  116.      * @var     string 
  117.      * @access    private
  118.      */
  119.     var $Host        = "";
  120.  
  121.     /**
  122.      * Does your SMTP host require SMTPAuth authentication?
  123.      * @var     boolean 
  124.      * @access    private
  125.      */
  126.     var $SMTPAuth    = FALSE;
  127.  
  128.     /**
  129.      * Username for authentication with your SMTP host.
  130.      * 
  131.      * Only used if {@link $Mailer} is "smtp" and {@link $SMTPAuth} is TRUE
  132.      * @var     string 
  133.      * @access    private
  134.      */
  135.     var $Username    = "";
  136.  
  137.     /**
  138.      * Password for SMTPAuth.
  139.      * 
  140.      * Only used if {@link $Mailer} is "smtp" and {@link $SMTPAuth} is TRUE
  141.      * @var     string 
  142.      * @access    private
  143.      */
  144.     var $Password    = "";
  145.     
  146.     /**
  147.      * Constuctor
  148.      * 
  149.      * @access public
  150.      * @return void 
  151.      * 
  152.      * @global    $xoopsConfig 
  153.      */
  154.     function XoopsMultiMailer(){
  155.         global $xoopsConfig;
  156.     
  157.         $config_handler =xoops_gethandler('config');
  158.         $xoopsMailerConfig =$config_handler->getConfigsByCat(XOOPS_CONF_MAILER);
  159.         $this->From = $xoopsMailerConfig['from'];
  160.         if ($this->From == ''{
  161.             $this->From = $xoopsConfig['adminmail'];
  162.         }
  163.         $this->Sender = $this->From;
  164.  
  165.         if ($xoopsMailerConfig["mailmethod"== "smtpauth"{
  166.             $this->Mailer = "smtp";
  167.             $this->SMTPAuth = TRUE;
  168.             // TODO: change value type of xoopsConfig "smtphost" from array to text
  169.             $this->Host = implode(';',$xoopsMailerConfig['smtphost']);
  170.             $this->Username = $xoopsMailerConfig['smtpuser'];
  171.             $this->Password = $xoopsMailerConfig['smtppass'];
  172.         else {
  173.             $this->Mailer = $xoopsMailerConfig['mailmethod'];
  174.             $this->SMTPAuth = FALSE;
  175.             $this->Sendmail = $xoopsMailerConfig['sendmailpath'];
  176.             $this->Host = implode(';',$xoopsMailerConfig['smtphost']);
  177.         }
  178.         $this->CharSet = strtolower_CHARSET );
  179.         if file_existsXOOPS_ROOT_PATH "/language/{$xoopsConfig['language']}/phpmailer.php) ) {
  180.             includeXOOPS_ROOT_PATH "/language/{$xoopsConfig['language']}/phpmailer.php);
  181.             $this->language $PHPMAILER_LANG;
  182.         else {
  183.             $this->SetLanguage'en'XOOPS_ROOT_PATH "/class/mail/phpmailer/language/" );
  184.         }
  185.     }
  186.  
  187.     /**
  188.      * Formats an address correctly. This overrides the default addr_format method which does not seem to encode $FromName correctly
  189.      * @access private
  190.      * @return string 
  191.      */
  192.     function AddrFormat($addr{
  193.         if(empty($addr[1]))
  194.             $formatted $addr[0];
  195.         else
  196.             $formatted sprintf('%s <%s>''=?'.$this->CharSet.'?B?'.base64_encode($addr[1]).'?='$addr[0]);
  197.  
  198.         return $formatted;
  199.     }
  200. }
  201.  
  202. ?>

XOOPS Docs generated by phpDocumentor