11 include_once
RMCPATH.
'/class/swift/swift_required.php';
58 $config_handler =& xoops_gethandler(
'config');
59 $xconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER);
63 switch($config[
'transport']){
68 $this->swTransport =
Swift_SmtpTransport::newInstance($config[
'smtp_server'], $config[
'smtp_port'], $config[
'smtp_crypt']!=
'none' ? $config[
'smtp_crypt'] :
'');
69 $this->swTransport->setUsername($config[
'smtp_user']);
70 $this->swTransport->setPassword($config[
'smtp_pass']);
80 $this->swMessage->setReplyTo($xconfig[
'from']);
81 $this->swMessage->setFrom(array($xconfig[
'from'] => $xconfig[
'fromname']));
82 $this->swMessage->setContentType($content_type);
87 $this->swMessage->setFrom($mail, $name);
91 if (strtolower(get_class($user))==
'xoopsuser')
92 $this->fromuser = $user;
94 $this->fromuser =
new XoopsUser($user);
124 return $this->swMessage->getSubject();
133 $this->swMessage->setSubject($subject);
141 return $this->swMessage->getBody();
152 $this->swMessage->setBody($body, $content_type!=
'' ? $content_type : $this->swMessage->getContentType());
181 if (trim(
$path)==
'' || !is_file(
$path))
return;
193 if (trim($name)!=
'') $att->setFilename($name);
194 if (trim($content_type)!=
'') $att->setContentType($content_type);
195 if (trim($disposition)!=
'') $att->setDisposition($disposition);
197 $this->swMessage->attach($att);
215 if (
$file==
'')
return;
230 public function set_to($recipients = array()){
231 if (empty($recipients))
return;
232 return $this->swMessage->setTo($recipients);
240 return $this->swMessage->getTo();
249 if ($mail==
'')
return;
250 return $this->swMessage->addTo($mail, $name);
257 public function set_cc($recipients = array()){
258 if (empty($recipients))
return;
259 return $this->swMessage->setCc($recipients);
267 return $this->swMessage->getCc();
276 if ($mail==
'')
return;
278 return $this->swMessage->addCc($mail, $name);
281 public function set_bcc($recipients = array()){
282 if (empty($recipients))
return;
283 return $this->swMessage->seBcc($recipients);
287 return $this->swMessage->getBcc();
291 if ($mail==
'')
return;
293 return $this->swMessage->addBcc($mail, $name);
303 if (!is_array(
$users))
return;
305 foreach (
$users as $user){
306 if (is_a($user,
"XoopsUser")){
307 $this->
add_user($user->getVar(
'email'), $user->getVar(
'name')!=
'' ? $user->getVar(
'name') : $user->getVar(
'uname'),
$field);
309 $user =
new XoopsUser($user);
310 if ($user->isNew())
continue;
311 $this->
add_user($user->getVar(
'email'), $user->getVar(
'name')!=
'' ? $user->getVar(
'name') : $user->getVar(
'uname'),
$field);
313 $this->xusers[] = $user;
321 $this->
add_to($mail, $name);
324 $this->
add_cc($mail, $name);
343 if (strtolower(get_class($user))==
'rmuser'){
344 $this->xusers[] = $user;
345 $this->
add_user($user->getVar(
'email'), $user->getVar(
'name')!=
'' ? $user->getVar(
'name') : $user->getVar(
'uname'),
$field);
352 if (strtolower(get_class(
$users))==
'xoopsuser'){
353 $this->xusers[] = $user;
366 if ($mail==
'')
return;
367 $this->swMessage->setReturnPath($mail);
370 return $this->swMessage->getReturnPath();
374 $this->vars[$var] = $value;
384 if (file_exists(
$file))
385 $this->
template =
$file;
400 if($this->
template==
'')
return;
402 if ($this->tpl_type==
'old'){
405 $ret = file_get_contents($this->
template);
407 foreach($this->vars as $name => $value){
408 $ret = str_replace(
'{'.$name.
'}', $value,
$ret);
416 extract($this->vars);
421 $ret = ob_get_clean();
429 if(empty($this->xusers))
432 if (!$this->fromuser)
437 $pm_handler = &xoops_gethandler(
'privmessage');
438 $pm = &$pm_handler->create();
441 $pm->setVar(
'from_userid', $this->fromuser->uid());
442 $pm->setVar(
"msg_text", $this->
get_body());
444 foreach($this->xusers as $user){
445 $pm->setVar(
"to_userid", $user->uid());
446 $pm_handler->insert($pm);
454 return $this->swMailer->batchSend($this->swMessage, $this->
errors);
460 return $this->swMailer->send($this->swMessage, $this->
errors);