179 $this->multimailer->isHTML($value);
189 $this->fromEmail =
"";
190 $this->fromName =
"";
191 $this->fromUser = null;
192 $this->priority =
'';
193 $this->toUsers = array();
194 $this->toEmails = array();
195 $this->headers = array();
198 $this->errors = array();
199 $this->success = array();
200 $this->isMail =
false;
202 $this->assignedTags = array();
203 $this->
template =
"";
204 $this->templatedir =
"";
216 if ($value === null &&
$xoops->isModule()) {
217 $value =
$xoops->module->getVar(
'dirname',
'n');
221 $this->templatedir = $value;
230 if (!
$path = $this->templatedir) {
232 } elseif (
false === strpos(
$path,
'/')) {
234 } elseif (substr(
$path, -1, 1) !=
"/") {
254 $this->
template = $value;
263 $this->fromEmail = trim($value);
272 $this->fromName = trim($value);
281 $this->fromUser =
$user;
290 $this->priority = trim($value);
299 $this->subject = trim($value);
308 $this->body = trim($value);
316 $this->isMail =
true;
331 public function send($debug =
false)
334 if ($this->body ==
"" && $this->
template ==
"") {
339 } elseif ($this->
template !=
"") {
341 if (!($fd = @fopen(
$path,
'r'))) {
351 if ($this->isMail || !empty($this->toEmails)) {
352 if (!empty($this->priority)) {
357 $headers = join($this->LE, $this->headers);
365 $this->
assign(
'X_ADMINMAIL',
$xoops->getConfig(
'adminmail'));
366 $this->
assign(
'X_SITENAME',
$xoops->getConfig(
'sitename'));
372 foreach ($this->assignedTags as $k => $v) {
373 $this->body = str_replace(
"{" . $k .
"}", $v, $this->body);
374 $this->subject = str_replace(
"{" . $k .
"}", $v, $this->subject);
376 $this->body = str_replace(
"\r\n",
"\n", $this->body);
377 $this->body = str_replace(
"\r",
"\n", $this->body);
378 $this->body = str_replace(
"\n", $this->LE, $this->body);
380 foreach ($this->toEmails as $mailaddr) {
395 foreach ($this->toUsers as
$user) {
400 $text = str_replace(
"{X_UEMAIL}", $user->getVar(
"email"),
$text);
401 $text = str_replace(
"{X_UNAME}", $user->getVar(
"uname"),
$text);
402 $text = str_replace(
"{X_UACTLINK}", \
XoopsBaseConfig::get(
'url') .
"/register.php?op=actv&id=" . $user->getVar(
"uid") .
"&actkey=" . $user->getVar(
'actkey'),
$text);
429 if (count($this->errors) > 0) {
448 $pm->setVar(
'from_userid', !empty($this->fromUser) ? $this->fromUser->getVar(
'uid') : (!
$xoops->isUser() ? 1
449 :
$xoops->user->getVar(
'uid')));
450 $pm->setVar(
"msg_text",
$body);
451 $pm->setVar(
"to_userid",
$uid);
452 $pm->setVar(
'msg_time', time());
474 $this->multimailer->ClearAllRecipients();
475 $this->multimailer->AddAddress(
$email);
476 $this->multimailer->Subject =
$subject;
477 $this->multimailer->Body =
$body;
480 if (!empty($this->fromName)) {
481 $this->multimailer->FromName = $this->
encodeFromName($this->fromName);
483 if (!empty($this->fromEmail)) {
487 $this->multimailer->ClearCustomHeaders();
488 foreach ($this->headers as
$header) {
489 $this->multimailer->AddCustomHeader($header);
491 if (!$this->multimailer->Send()) {
492 $this->errors[] = $this->multimailer->ErrorInfo;
508 if (!empty($this->errors)) {
510 foreach ($this->errors as
$error) {
511 $ret .= $error .
"<br />";
525 if (!empty($this->success)) {
526 foreach ($this->success as $suc) {
527 $ret .= $suc .
"<br />";
539 public function assign($tag, $value = null)
541 if (is_array($tag)) {
542 foreach ($tag as $k => $v) {
546 if (!empty($tag) && isset($value)) {
547 $tag = strtoupper(trim($tag));
551 $this->assignedTags[$tag] = $value;
563 $this->headers[] = trim($value) .
$this->LE;
575 array_push($this->toEmails,
$email);
590 if (is_a($users,
'XoopsUser')) {
591 array_push($this->toUsers, $users);
592 } elseif (is_array($users)) {
593 foreach ($users as $u) {
605 if (is_a(
$groups,
'XoopsGroup')) {
608 ->getUsersByGroup(
$groups->getVar(
'groupid'),
true));
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
sendMail($email, $subject, $body, $headers)
setTemplateDir($value=null)
setFromUser(XoopsUser $user)
defined('DS') or define('DS' DIRECTORY_SEPARATOR
const EF_EMAIL_NOT_SENT_TO
assign($tag, $value=null)
const EF_PRIVATE_MESSAGE_NOT_SENT_TO
const E_TEMPLATE_FILE_NOT_OPENED
if(!$xoops->isUser()) $uid
sendPM($uid, $subject, $body)
const E_MESSAGE_BODY_NOT_SET
const SF_PRIVATE_MESSAGE_SENT_TO