31 public $mConvertLocal =
null;
33 public function __construct()
36 $this->mConvertLocal->register(
'Legacy_Mailer.ConvertLocal');
41 public function prepare()
43 $root = XCube_Root::getSingleton();
44 $handler = xoops_gethandler(
'config');
45 $xoopsMailerConfig = $handler->getConfigsByCat(XOOPS_CONF_MAILER);
48 if (
'' === $xoopsMailerConfig[
'from']) {
49 $this->From = $root->mContext->mXoopsConfig[
'adminmail'];
51 $this->From = $xoopsMailerConfig[
'from'];
54 $this->Sender = $root->mContext->mXoopsConfig[
'adminmail'];
55 $this->SetLanguage(LEGACY_MAIL_LANG, XOOPS_ROOT_PATH.
'/class/mail/phpmailer/language/');
56 $this->CharSet = LEGACY_MAIL_CHAR;
57 $this->Encoding = LEGACY_MAIL_ENCO;
59 switch ($xoopsMailerConfig[
'mailmethod']) {
62 $this->SMTPAuth =
true;
63 $this->Host = implode(
';', $xoopsMailerConfig[
'smtphost']);
64 $this->Username = $xoopsMailerConfig[
'smtpuser'];
65 $this->Password = $xoopsMailerConfig[
'smtppass'];
70 $this->SMTPAuth =
false;
71 $this->Host = implode(
';', $xoopsMailerConfig[
'smtphost']);
76 $this->Sendmail = $xoopsMailerConfig[
'sendmailpath'];
83 public function setFromEmail($text)
88 public function setFromName($text)
90 $this->FromName = $this->convertLocal($this->SecureHeader($text),
true);
93 public function setSubject($text)
95 $this->Subject = $text;
98 public function setBody($text)
100 $search = [
"\r\n",
"\r",
"\n"];
101 $replace = [
"\n",
"\n", self::$LE];
102 $text = str_replace($search, $replace, $text);
103 $this->Body = $this->convertLocal($text);
106 public function setToEmails($email)
108 $this->AddAddress($email,
'');
111 public function setTo($add, $name =
'')
113 $this->AddAddress($add, $name);
116 public function reset()
118 $this->ClearAllRecipients();
123 public function send()
128 public function EncodeHeader($str, $position =
'text')
130 if (
'text' === $position) {
131 return $this->convertLocal($str,
true);
133 return parent::EncodeHeader($str, $position);
137 private function convertLocal($text, $mime =
false)
139 if (_LANGCODE ===
'ja') {
140 $text = $this->_Japanese_convLocal($text, $mime);
142 $this->mConvertLocal->call(
new XCube_Ref($text), $mime);
147 private function _Japanese_convLocal($text, $mime)
150 $text = mb_encode_mimeheader($text, LEGACY_MAIL_CHAR,
'B', $this->LE);
152 $text = mb_convert_encoding($text,
'JIS', _CHARSET);