50 lines
		
	
	
		
			924 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			924 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace kernel;
 | 
						|
 | 
						|
use kernel\helpers\Debug;
 | 
						|
use kernel\helpers\SMTP;
 | 
						|
use PHPMailer\PHPMailer\Exception;
 | 
						|
 | 
						|
class Mailing
 | 
						|
{
 | 
						|
    protected SMTP $SMTP;
 | 
						|
 | 
						|
    protected CgView $cgView;
 | 
						|
    protected array $data;
 | 
						|
 | 
						|
    public function __construct(array $data = [])
 | 
						|
    {
 | 
						|
        $this->cgView = new CgView();
 | 
						|
        $this->cgView->viewPath = KERNEL_DIR . "/views/mailing/";
 | 
						|
 | 
						|
        $this->data = $data;
 | 
						|
 | 
						|
        $this->SMTP = new SMTP();
 | 
						|
 | 
						|
        $this->init();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @throws Exception
 | 
						|
     */
 | 
						|
    public function send_html(string $tpl, array $tplParams, array $mailParams): ?false
 | 
						|
    {
 | 
						|
        $mailParams['body'] = $this->cgView->fetch($tpl, $tplParams);
 | 
						|
        return $this->SMTP->send_html($mailParams);
 | 
						|
    }
 | 
						|
 | 
						|
    public function run()
 | 
						|
    {
 | 
						|
    }
 | 
						|
 | 
						|
    public static function create(array $data = []): static
 | 
						|
    {
 | 
						|
        return new static($data);
 | 
						|
    }
 | 
						|
 | 
						|
    protected function init()
 | 
						|
    {
 | 
						|
    }
 | 
						|
 | 
						|
} |