XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
xoopsmultimailer.php
1<?php
13
14if (!defined('XOOPS_ROOT_PATH')) {
15 exit();
16}
17
21require XOOPS_ROOT_PATH .'/class/mail/phpmailer/src/Exception.php';
22require XOOPS_ROOT_PATH .'/class/mail/phpmailer/src/PHPMailer.php';
23require XOOPS_ROOT_PATH .'/class/mail/phpmailer/src/SMTP.php';
24
25use PHPMailer\PHPMailer\PHPMailer;
26
34class xoopsmultimailer extends PHPMailer
35{
36
42 public $From = '';
43
49 public $FromName = '';
50
51 // can be "smtp", "sendmail", or "mail"
66 public $Mailer = 'mail';
67
76 public $Sendmail = '/usr/sbin/sendmail';
77
85 public $Host = '';
86
92 public $SMTPAuth = false;
93
101 public $Username = '';
102
110 public $Password = '';
111
120 public function __construct()
121 {
122 global $xoopsConfig;
123 $this->ClearAllRecipients();
124 $config_handler = &xoops_gethandler('config');
125 $xoopsMailerConfig = &$config_handler->getConfigsByCat(XOOPS_CONF_MAILER);
126 $this->From = $xoopsMailerConfig['from'];
127 if ('' == $this->From) {
128 $this->From = defined('XOOPS_NOTIFY_FROM_EMAIL') ? XOOPS_NOTIFY_FROM_EMAIL : $xoopsConfig['adminmail'];
129 }
130 $this->Sender = defined('XOOPS_NOTIFY_SENDER_EMAIL') ? XOOPS_NOTIFY_SENDER_EMAIL : $xoopsConfig['adminmail'];
131 if ('smtpauth' == $xoopsMailerConfig['mailmethod']) {
132 $this->Mailer = 'smtp';
133 $this->SMTPAuth = true;
134 $this->Host = implode(';', $xoopsMailerConfig['smtphost']);
135 $this->Username = $xoopsMailerConfig['smtpuser'];
136 $this->Password = $xoopsMailerConfig['smtppass'];
137 } else {
138 $this->Mailer = $xoopsMailerConfig['mailmethod'];
139 $this->SMTPAuth = false;
140 $this->Sendmail = $xoopsMailerConfig['sendmailpath'];
141 $this->Host = implode(';', $xoopsMailerConfig['smtphost']);
142 }
143 }
144
153 //TODO: We must verify,whether we should prepare this method even now.(phpmailer is upgraded from 1.65 to 1.73)
154 public function AddrFormat($addr)
155 {
156 if (empty($addr[1])) {
157 $formatted = $addr[0];
158 } else {
159 $formatted = sprintf('%s <%s>', '=?' . $this->CharSet . '?B?' . base64_encode($addr[1]) . '?=', $addr[0]);
160 }
161
162 return $formatted;
163 }
164
169
170 public function Send()
171 {
172 if (
173 empty($this->Sender)
174 || preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $this->Sender)
175 ) {
176 return parent::Send();
177 }
178 return false;
179 }
180
190 public function SetLanguage($lang_type = 'en', $lang_path = 'language/')
191 {
192 // Patch for XOOPSCube Legacy 2008/09/21
193 $ext = substr($lang_path, -1, 1);
194 if ('/' !== $ext && file_exists($lang_path)) {
195 include($lang_path);
196 $this->language = $PHPMAILER_LANG;
197 return true;
198 }
199
200 return parent::SetLanguage($lang_type, $lang_path);
201 }
202}
SetLanguage($lang_type='en', $lang_path='language/')