| 1 | <?php |
|---|
| 2 | // $Id: xoopsmultimailer.php,v 1.3 2006/05/01 02:37:24 onokazu Exp $ |
|---|
| 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 ([email protected]) // |
|---|
| 28 | // URL: http://www.xoops.org // |
|---|
| 29 | // Project: The XOOPS Project // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | /** |
|---|
| 32 | * @package class |
|---|
| 33 | * @subpackage mail |
|---|
| 34 | * |
|---|
| 35 | * @filesource |
|---|
| 36 | * |
|---|
| 37 | * @author Jochen Büînagel <[email protected]> |
|---|
| 38 | * @copyright copyright (c) 2000-2003 The XOOPS Project (http://www.xoops.org) |
|---|
| 39 | * |
|---|
| 40 | * @version $Revision: 1.3 $ - $Date: 2006/05/01 02:37:24 $ |
|---|
| 41 | */ |
|---|
| 42 | |
|---|
| 43 | /** |
|---|
| 44 | * load the base class |
|---|
| 45 | */ |
|---|
| 46 | require_once(XOOPS_ROOT_PATH.'/class/mail/phpmailer/class.phpmailer.php'); |
|---|
| 47 | |
|---|
| 48 | /** |
|---|
| 49 | * Mailer Class. |
|---|
| 50 | * |
|---|
| 51 | * At the moment, this does nothing but send email through PHP's "mail()" function, |
|---|
| 52 | * but it has the abiltiy to do much more. |
|---|
| 53 | * |
|---|
| 54 | * If you have problems sending mail with "mail()", you can edit the member variables |
|---|
| 55 | * to suit your setting. Later this will be possible through the admin panel. |
|---|
| 56 | * |
|---|
| 57 | * @todo Make a page in the admin panel for setting mailer preferences. |
|---|
| 58 | * |
|---|
| 59 | * @package class |
|---|
| 60 | * @subpackage mail |
|---|
| 61 | * |
|---|
| 62 | * @author Jochen Buennagel <[email protected]> |
|---|
| 63 | * @copyright (c) 2000-2003 The Xoops Project - www.xoops.org |
|---|
| 64 | * @version $Revision: 1.3 $ - changed by $Author: onokazu $ on $Date: 2006/05/01 02:37:24 $ |
|---|
| 65 | */ |
|---|
| 66 | class XoopsMultiMailer extends PHPMailer { |
|---|
| 67 | |
|---|
| 68 | /** |
|---|
| 69 | * "from" address |
|---|
| 70 | * @var string |
|---|
| 71 | * @access private |
|---|
| 72 | */ |
|---|
| 73 | var $From = ""; |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * "from" name |
|---|
| 77 | * @var string |
|---|
| 78 | * @access private |
|---|
| 79 | */ |
|---|
| 80 | var $FromName = ""; |
|---|
| 81 | |
|---|
| 82 | // can be "smtp", "sendmail", or "mail" |
|---|
| 83 | /** |
|---|
| 84 | * Method to be used when sending the mail. |
|---|
| 85 | * |
|---|
| 86 | * This can be: |
|---|
| 87 | * <li>mail (standard PHP function "mail()") (default) |
|---|
| 88 | * <li>smtp (send through any SMTP server, SMTPAuth is supported. |
|---|
| 89 | * You must set {@link $Host}, for SMTPAuth also {@link $SMTPAuth}, |
|---|
| 90 | * {@link $Username}, and {@link $Password}.) |
|---|
| 91 | * <li>sendmail (manually set the path to your sendmail program |
|---|
| 92 | * to something different than "mail()" uses in {@link $Sendmail}) |
|---|
| 93 | * |
|---|
| 94 | * @var string |
|---|
| 95 | * @access private |
|---|
| 96 | */ |
|---|
| 97 | var $Mailer = "mail"; |
|---|
| 98 | |
|---|
| 99 | /** |
|---|
| 100 | * set if $Mailer is "sendmail" |
|---|
| 101 | * |
|---|
| 102 | * Only used if {@link $Mailer} is set to "sendmail". |
|---|
| 103 | * Contains the full path to your sendmail program or replacement. |
|---|
| 104 | * @var string |
|---|
| 105 | * @access private |
|---|
| 106 | */ |
|---|
| 107 | var $Sendmail = "/usr/sbin/sendmail"; |
|---|
| 108 | |
|---|
| 109 | /** |
|---|
| 110 | * SMTP Host. |
|---|
| 111 | * |
|---|
| 112 | * Only used if {@link $Mailer} is set to "smtp" |
|---|
| 113 | * @var string |
|---|
| 114 | * @access private |
|---|
| 115 | */ |
|---|
| 116 | var $Host = ""; |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | * Does your SMTP host require SMTPAuth authentication? |
|---|
| 120 | * @var boolean |
|---|
| 121 | * @access private |
|---|
| 122 | */ |
|---|
| 123 | var $SMTPAuth = FALSE; |
|---|
| 124 | |
|---|
| 125 | /** |
|---|
| 126 | * Username for authentication with your SMTP host. |
|---|
| 127 | * |
|---|
| 128 | * Only used if {@link $Mailer} is "smtp" and {@link $SMTPAuth} is TRUE |
|---|
| 129 | * @var string |
|---|
| 130 | * @access private |
|---|
| 131 | */ |
|---|
| 132 | var $Username = ""; |
|---|
| 133 | |
|---|
| 134 | /** |
|---|
| 135 | * Password for SMTPAuth. |
|---|
| 136 | * |
|---|
| 137 | * Only used if {@link $Mailer} is "smtp" and {@link $SMTPAuth} is TRUE |
|---|
| 138 | * @var string |
|---|
| 139 | * @access private |
|---|
| 140 | */ |
|---|
| 141 | var $Password = ""; |
|---|
| 142 | |
|---|
| 143 | /** |
|---|
| 144 | * Constuctor |
|---|
| 145 | * |
|---|
| 146 | * @access public |
|---|
| 147 | * @return void |
|---|
| 148 | * |
|---|
| 149 | * @global $xoopsConfig |
|---|
| 150 | */ |
|---|
| 151 | function XoopsMultiMailer(){ |
|---|
| 152 | global $xoopsConfig; |
|---|
| 153 | |
|---|
| 154 | $config_handler =& xoops_gethandler('config'); |
|---|
| 155 | $xoopsMailerConfig =& $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); |
|---|
| 156 | $this->From = $xoopsMailerConfig['from']; |
|---|
| 157 | if ($this->From == '') { |
|---|
| 158 | $this->From = $xoopsConfig['adminmail']; |
|---|
| 159 | } |
|---|
| 160 | // $this->Sender = $xoopsConfig['adminmail']; //TODO: This line is added in OTX by Marijuana. We must verify. |
|---|
| 161 | if ($xoopsMailerConfig["mailmethod"] == "smtpauth") { |
|---|
| 162 | $this->Mailer = "smtp"; |
|---|
| 163 | $this->SMTPAuth = TRUE; |
|---|
| 164 | $this->Host = implode(';',$xoopsMailerConfig['smtphost']); |
|---|
| 165 | $this->Username = $xoopsMailerConfig['smtpuser']; |
|---|
| 166 | $this->Password = $xoopsMailerConfig['smtppass']; |
|---|
| 167 | } else { |
|---|
| 168 | $this->Mailer = $xoopsMailerConfig['mailmethod']; |
|---|
| 169 | $this->SMTPAuth = FALSE; |
|---|
| 170 | $this->Sendmail = $xoopsMailerConfig['sendmailpath']; |
|---|
| 171 | $this->Host = implode(';',$xoopsMailerConfig['smtphost']); |
|---|
| 172 | } |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | /** |
|---|
| 176 | * Formats an address correctly. This overrides the default AddrFormat method |
|---|
| 177 | * which does not seem to encode $FromName correctly |
|---|
| 178 | * This method name is renamed from "addr_format", because method name in parent class is renamed. |
|---|
| 179 | * @access private |
|---|
| 180 | * @return string |
|---|
| 181 | */ |
|---|
| 182 | //TODO: We must verify,whether we should prepare this method even now.(phpmailer is upgraded from 1.65 to 1.73) |
|---|
| 183 | function AddrFormat($addr) { |
|---|
| 184 | if(empty($addr[1])) |
|---|
| 185 | $formatted = $addr[0]; |
|---|
| 186 | else |
|---|
| 187 | $formatted = sprintf('%s <%s>', '=?'.$this->CharSet.'?B?'.base64_encode($addr[1]).'?=', $addr[0]); |
|---|
| 188 | |
|---|
| 189 | return $formatted; |
|---|
| 190 | } |
|---|
| 191 | } |
|---|
| 192 | ?> |
|---|