XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Mailer.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
18class Legacy_Mailer extends PHPMailer
19{
23 public $mConvertLocal = null;
24
25 public function __construct()
26 {
27 $this->mConvertLocal =new XCube_Delegate();
28 $this->mConvertLocal->register('Legacy_Mailer.ConvertLocal');
29 }
30
31 public function prepare()
32 {
33 $root =& XCube_Root::getSingleton();
34
35 $handler =& xoops_gethandler('config');
36 $xoopsMailerConfig =& $handler->getConfigsByCat(XOOPS_CONF_MAILER);
37 $this->reset();
38
39 if ('' == $xoopsMailerConfig['from']) {
40 $this->From = $root->mContext->mXoopsConfig['adminmail'];
41 } else {
42 $this->From = $xoopsMailerConfig['from'];
43 }
44
45 $this->Sender = $root->mContext->mXoopsConfig['adminmail'];
46
47 $this->SetLanguage = LEGACY_MAIL_LANG;
48 $this->CharSet = LEGACY_MAIL_CHAR;
49 $this->Encoding = LEGACY_MAIL_ENCO;
50
51 switch ($xoopsMailerConfig['mailmethod']) {
52 case 'smtpauth':
53 $this->IsSMTP();
54 $this->SMTPAuth = true;
55 $this->Host = implode(';', $xoopsMailerConfig['smtphost']);
56 $this->Username = $xoopsMailerConfig['smtpuser'];
57 $this->Password = $xoopsMailerConfig['smtppass'];
58 break;
59
60 case 'smtp':
61 $this->IsSMTP();
62 $this->SMTPAuth = false;
63 $this->Host = implode(';', $xoopsMailerConfig['smtphost']);
64 break;
65
66 case 'sendmail':
67 $this->IsSendmail();
68 $this->Sendmail = $xoopsMailerConfig['sendmailpath'];
69 break;
70 }
71
72 return true;
73 }
74
75 public function setFrom($text)
76 {
77 $this->From = $text;
78 }
79
80 public function setFromname($text)
81 {
82 $this->FromName = $this->convertLocal($text, 2);
83 }
84
85 public function setSubject($text)
86 {
87 $this->Subject = $this->convertLocal($text, true);
88 }
89
90 public function setBody($text)
91 {
92 $this->Body = $this->convertLocal($text);
93 }
94
95 public function setTo($add, $name)
96 {
97 $this->AddAddress($add, $this->convertLocal($name, true));
98 }
99
100 public function reset()
101 {
102 $this->ClearAllRecipients();
103 $this->Body = '';
104 $this->Subject = '';
105 }
106
107 public function convertLocal($text, $mime = false)
108 {
109 $this->mConvertLocal->call(new XCube_Ref($text), $mime);
110 return $text;
111 }
112}
[Final] Used for the simple mechanism for common delegation in XCube.