ACC SHELL
<?php
// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
class Mail
{
public $to = array();
public $bcc = array();
public $from = '';
public $subject = '';
public $body = '';
public $headers = array();
public $attachments = array();
private $_subject = '';
private $_body = '';
public function prepare()
{
if ($this->subject instanceof Template)
$this->_subject = $this->subject->process(array('mail' => $this));
else
$this->_subject = $this->subject;
if ($this->body instanceof Template)
$this->_body = $this->body->process(array('mail' => $this));
else
$this->_body = $this->body;
}
public function send()
{
return self::m($this->to, $this->bcc, $this->_subject, $this->_body, $this->from, $this->headers, $this->attachments);
}
public function prepareAndSend()
{
$this->prepare();
return $this->send();
}
public static function pseudoSmarty($template, $args = array())
{
return Template::pseudoSmarty($template, array_merge(array('site' => $GLOBALS["site"], 'page' => $GLOBALS["page"]), $args));
}
public static function m($to, $bcc, $subject, $body, $from = null, $headers = array(), $attachments = array())
{
require_once('third-party/phpmailer/class.phpmailer.php');
if ($from === null)
$from = DEFAULT_EMAIL;
$from = explode('|', $from);
if (!is_array($to))
$to = array($to);
if (!is_array($bcc))
$bcc = array($bcc);
if (!is_array($attachments))
$attachments = array($attachments);
$text = strip_tags(str_replace(array('<br/>', '</div>', '</p>'), array("\n", "\n</div>", "\n</p>"), $body));
$mail = new PHPMailer();
$mail->IsMail();
$mail->CharSet = 'utf-8';
$mail->Encoding = 'quoted-printable';
$mail->From = $from[0];
$mail->FromName = (isset($from[1]) ? $from[1] : '');
$mail->Subject = $subject;
$mail->Body = $body;
foreach ($headers as $k => $v)
$mail->AddCustomHeader($k.':'.$v);
if ($text != $body)
$mail->IsHTML(true);
//$mail->AltBody = trim($text);
foreach ($attachments as $attachment)
{
if (isset($attachment['content']))
$mail->AddStringAttachment($attachment['content'], $attachment['name'], 'base64', $attachment['type']);
else
$mail->AddStringAttachment(file_get_contents($attachment['file']), $attachment['name'], 'base64', $attachment['type']);
}
foreach ($to as $email)
{
$email = explode('|', $email);
if (isset($email[1]))
$mail->AddAddress($email[0], $email[1]);
else
$mail->AddAddress($email[0]);
}
foreach ($bcc as $email)
{
$email = explode('|', $email);
if (isset($email[1]))
$mail->AddBCC($email[0], $email[1]);
else
$mail->AddBCC($email[0]);
}
return $mail->Send();
}
}
?>
ACC SHELL 2018