Files
zurawik.pl/core/class/Mailer.class.php
2026-05-15 18:33:51 +02:00

101 lines
2.1 KiB
PHP

<?php
require_once("../core/lib/phpmailer/class.phpmailer.php");
/**
* Description of Mailer
*
* @author KoPi
*/
class Mailer extends PHPMailer{
public static $c_name = '__img_mail_container_3456__';
public static $attachImages = true;
private $head;
private $bottom;
function __construct() {
$this->Config();
$this->SetDefaultHtml();
}
private function Config()
{
$this->Host='mediaflex.pl';
$this->IsSMTP();
$this->SetLanguage('pl', '../core/lib/phpmailer/language/');
$this->Mailer='smtp';
$this->Username = 'egw@mediaflex.pl';
$this->Password = 'EgW_2009';
$this->SMTPAuth = true;
$this->From= 'egw@mediaflex.pl';
$this->FromName = 'NASZA MEDYCYNA';
$this->ContentType = 'text/html';
$this->Ishtml(true);
}
private function SetDefaultHtml()
{
}
public function SendEmail($body,$altbody,$subject,$emails = null)
{
$this->Subject = $subject;
if(is_array($emails))
{
foreach ($emails as $index => $value) {
$this->AddAddress($value);
}
}
else {
if(!empty($emails)) {
$this->AddAddress($emails);
}
}
$this->Body = $this->head . $body . $this->bottom;
$this->AltBody = $altbody;
if(Mailer::$attachImages) {
$imgContainer = Registry::Get(Mailer::$c_name);
if(!empty($imgContainer)) {
foreach($imgContainer as $img) {
$this->AddEmbeddedImage(PATH_STATIC_CONTENT . 'image' . DIRECTORY_SEPARATOR . $img['img'], $img['name'], $img['img']);
}
}
}
if(!$this->Send())
{
return false;
}
else
{
$this->ClearAttachments();
$this->ClearAddresses();
$this->ClearAttachments();
return true;
}
}
public function GetHead() {
return $this->head;
}
public function SetHead($head) {
$this->head = $head;
}
public function GetBottom() {
return $this->bottom;
}
public function SetBottom($bottom) {
$this->bottom = $bottom;
}
}
?>