1: | <?php |
2: | /** |
3: | * Xoops MultiMailer Base Class |
4: | * |
5: | * You may not change or alter any portion of this comment or credits |
6: | * of supporting developers from this source code or any supporting source code |
7: | * which is considered copyrighted (c) material of the original comment or credit authors. |
8: | * This program is distributed in the hope that it will be useful, |
9: | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10: | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11: | * |
12: | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
13: | * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
14: | * @package Kernel |
15: | * @subpackage mail |
16: | * @since 2.0.0 |
17: | * @author Author: Jochen Büînagel (job@buennagel.com) |
18: | */ |
19: | |
20: | /** |
21: | * |
22: | * @package class |
23: | * @subpackage mail |
24: | * @filesource |
25: | * @author Jochen Büînagel <jb@buennagel.com> |
26: | */ |
27: | |
28: | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
29: | /** |
30: | * load the base class |
31: | */ |
32: | if (!file_exists($file = XOOPS_ROOT_PATH . '/class/mail/phpmailer/class.phpmailer.php')) { |
33: | trigger_error('Required File ' . str_replace(XOOPS_ROOT_PATH, '', $file) . ' was not found in file ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING); |
34: | |
35: | return false; |
36: | } |
37: | require_once XOOPS_ROOT_PATH . '/class/mail/phpmailer/PHPMailerAutoload.php'; |
38: | //include_once XOOPS_ROOT_PATH . '/class/mail/phpmailer/class.phpmailer.php'; |
39: | |
40: | /** |
41: | * Mailer Class. |
42: | * |
43: | * At the moment, this does nothing but send email through PHP "mail()" function, |
44: | * but it has the ability to do much more. |
45: | * |
46: | * If you have problems sending mail with "mail()", you can edit the member variables |
47: | * to suit your setting. Later this will be possible through the admin panel. |
48: | * |
49: | * @todo Make a page in the admin panel for setting mailer preferences. |
50: | * @package class |
51: | * @subpackage mail |
52: | * @author Jochen Buennagel <job@buennagel.com> |
53: | */ |
54: | class XoopsMultiMailer extends PHPMailer |
55: | { |
56: | /** |
57: | * 'from' address |
58: | * |
59: | * @var string |
60: | * @access private |
61: | */ |
62: | public $From = ''; |
63: | |
64: | /** |
65: | * 'from' name |
66: | * |
67: | * @var string |
68: | * @access private |
69: | */ |
70: | public $FromName = ''; |
71: | |
72: | // can be 'smtp', 'sendmail', or 'mail' |
73: | /** |
74: | * Method to be used when sending the mail. |
75: | * |
76: | * This can be: |
77: | * <li>mail (standard PHP function 'mail()') (default) |
78: | * <li>smtp (send through any SMTP server, SMTPAuth is supported. |
79: | * You must set {@link $Host}, for SMTPAuth also {@link $SMTPAuth}, |
80: | * {@link $Username}, and {@link $Password}.) |
81: | * <li>sendmail (manually set the path to your sendmail program |
82: | * to something different than 'mail()' uses in {@link $Sendmail}) |
83: | * |
84: | * @var string |
85: | * @access private |
86: | */ |
87: | public $Mailer = 'mail'; |
88: | |
89: | /** |
90: | * set if $Mailer is 'sendmail' |
91: | * |
92: | * Only used if {@link $Mailer} is set to 'sendmail'. |
93: | * Contains the full path to your sendmail program or replacement. |
94: | * |
95: | * @var string |
96: | * @access private |
97: | */ |
98: | public $Sendmail = '/usr/sbin/sendmail'; |
99: | |
100: | /** |
101: | * SMTP Host. |
102: | * |
103: | * Only used if {@link $Mailer} is set to 'smtp' |
104: | * |
105: | * @var string |
106: | * @access private |
107: | */ |
108: | public $Host = ''; |
109: | |
110: | /** |
111: | * Does your SMTP host require SMTPAuth authentication? |
112: | * |
113: | * @var boolean |
114: | * @access private |
115: | */ |
116: | public $SMTPAuth = false; |
117: | |
118: | /** |
119: | * Username for authentication with your SMTP host. |
120: | * |
121: | * Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE |
122: | * |
123: | * @var string |
124: | * @access private |
125: | */ |
126: | public $Username = ''; |
127: | |
128: | /** |
129: | * Password for SMTPAuth. |
130: | * |
131: | * Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE |
132: | * |
133: | * @var string |
134: | * @access private |
135: | */ |
136: | public $Password = ''; |
137: | |
138: | /** |
139: | * Constructor |
140: | * |
141: | * @access public |
142: | */ |
143: | public function __construct() |
144: | { |
145: | parent::__construct(); |
146: | /** @var XoopsConfigHandler $config_handler */ |
147: | $config_handler = xoops_getHandler('config'); |
148: | $xoopsMailerConfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); |
149: | $this->From = $xoopsMailerConfig['from']; |
150: | if ($this->From == '') { |
151: | $this->From = $GLOBALS['xoopsConfig']['adminmail']; |
152: | } |
153: | $this->Sender = $this->From; |
154: | if ($xoopsMailerConfig['mailmethod'] === 'smtpauth') { |
155: | $this->Mailer = 'smtp'; |
156: | $this->SMTPAuth = true; |
157: | // TODO: change value type of xoopsConfig 'smtphost' from array to text |
158: | $this->Host = implode(';', $xoopsMailerConfig['smtphost']); |
159: | $this->Username = $xoopsMailerConfig['smtpuser']; |
160: | $this->Password = $xoopsMailerConfig['smtppass']; |
161: | } else { |
162: | $this->Mailer = $xoopsMailerConfig['mailmethod']; |
163: | $this->SMTPAuth = false; |
164: | $this->Sendmail = $xoopsMailerConfig['sendmailpath']; |
165: | $this->Host = implode(';', $xoopsMailerConfig['smtphost']); |
166: | } |
167: | $this->CharSet = strtolower(_CHARSET); |
168: | $xoopsLanguage = preg_replace('/[^a-zA-Z0-9_-]/', '', $GLOBALS['xoopsConfig']['language']); |
169: | if (file_exists(XOOPS_ROOT_PATH . '/language/' . $xoopsLanguage . '/phpmailer.php')) { |
170: | include XOOPS_ROOT_PATH . '/language/' . $xoopsLanguage . '/phpmailer.php'; |
171: | $this->language = $PHPMAILER_LANG; |
172: | } else { |
173: | $this->setLanguage('en', XOOPS_ROOT_PATH . '/class/mail/phpmailer/language/'); |
174: | } |
175: | //$this->pluginDir = XOOPS_ROOT_PATH . '/class/mail/phpmailer/'; |
176: | } |
177: | |
178: | |
179: | } |
180: |