D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
adms
/
Models
/
helper
/
Filename :
AdmsPhpMailerBoleto.php
back
Copy
<?php namespace App\adms\Models\helper; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of AdmsPhpMailerBoleto * * @author Celke */ class AdmsPhpMailerBoleto { private $Resultado; private $DadosCredEmail; private $Dados; function getResultado() { return $this->Resultado; } public function emailPhpMailer( $Dados) { $this->Dados = $Dados; $credEmail = new \App\adms\Models\helper\AdmsRead(); $credEmail->fullRead("SELECT * FROM adms_confs_emails WHERE id =:id LIMIT :limit", "id=1&limit=1"); $this->DadosCredEmail = $credEmail->getResultado(); if ((isset($this->DadosCredEmail[0]['host'])) AND ( !empty($this->DadosCredEmail[0]['host']))) { // echo "Entrou para chamar "; $this->confEmail(); } else { $_SESSION['msg'] = "<div class='alert alert-danger'>Erro: Necessário inserir as credencias do e-mail no administrativo para enviar e-mail!</div>"; $this->Resultado = false; } } private function confEmail() { // echo "To aqui"; $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings // $mail->SMTPDebug = 1; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $this->DadosCredEmail[0]['host']; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $this->DadosCredEmail[0]['usuario']; // SMTP username $mail->Password = $this->DadosCredEmail[0]['senha']; // SMTP password $mail->SMTPSecure = $this->DadosCredEmail[0]['smtpsecure']; // Enable TLS encryption, `ssl` also accepted $mail->Port = $this->DadosCredEmail[0]['porta']; // TCP port to connect to $mail->isHTML(true); // Set email format to HTML $mail->setFrom($this->DadosCredEmail[0]['email'], $this->DadosCredEmail[0]['nome']); $mail->addAddress($this->Dados['dest_email'], $this->Dados['dest_nome']); //$mail->addAddress('anderson.felix@devcodes.com.br', 'Anderson Felix'); // Add a recipient // Set email format to HTML $mail->Subject = $this->Dados['Subject']; $mail->Body = $this->Dados['body']; $mail->AltBody = $this->Dados['body']; $mail->addAttachment($this->Dados['anexo'], "boleto.pdf" ); if(!$mail->send()){ echo "Erro". $mail->ErrorInfo; } /* if($mail->send()){ echo "Enviado"; }else{ echo "Erro". $mail->ErrorInfo; } */ } catch (Exception $e) { $this->Resultado = false; } } }