Guest User

Untitled

a guest
Aug 26th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Classe reponsável pelo envio de e-mails na aplicação
  5. *
  6. */
  7. class EmailHelper {
  8.  
  9. /**
  10. * Recebe as configurações de envio
  11. * @var $config = array
  12. */
  13. public $config = array(
  14. "USER"=> "",//User E-mail
  15. "PASS"=> "",//User Pass
  16. "PORT"=> "",//PORT
  17. "HOST"=> ""//SMTP SERVER
  18. );
  19.  
  20. public $subject = "Envio de email";
  21.  
  22. public $toEmail = "pedidosite@helpmicros.com.br";
  23. public $toName = "Help Micros";
  24. public $fromEmail;
  25. public $fromName;
  26. public $body;
  27. public $htmlMessage;
  28.  
  29. public function sendMail() {
  30.  
  31. date_default_timezone_set('America/Sao_Paulo');
  32.  
  33. $mail = new PHPMailer();
  34. $mail->SetLanguage('en');
  35. $mail->IsSMTP();
  36. $mail->SMTPDebug = 1;
  37.  
  38. //Configurações de Envio
  39. $mail->SMTPAuth = true;
  40.  
  41. //$mail->SMTPSecure = $this->config["SSL"];
  42. $mail->Host = $this->config["HOST"];
  43. $mail->Port = $this->config["PORT"];
  44. $mail->Username = $this->config["USER"];
  45. $mail->Password = $this->config["PASS"];
  46.  
  47. //Adiciona Cópia para o Destinatário da Mensagem
  48. $mail->AddCC($this->fromEmail, $this->fromName);
  49.  
  50. //Envio
  51. $mail->SetFrom($this->toEmail, 'Help Micros');
  52. $mail->AddReplyTo($this->fromEmail, $this->fromEmail);
  53.  
  54. $mail->Subject = $this->subject;
  55. $mail->AltBody = "Para visualizar a mensagem, por favor, use um cliente de e-mail
  56. compatível/configurado para ver mensagens HTML!";
  57.  
  58. $mail->MsgHTML(utf8_decode($this->htmlMessage));
  59.  
  60. $mail->AddAddress($this->toEmail, $this->toName);
  61.  
  62. if (!$mail->Send()) {
  63. echo "Erro: " . $mail->ErrorInfo;
  64. exit;
  65. } else {
  66. return true;
  67. }
  68.  
  69. $mail->ClearAllRecipients();
  70.  
  71. }
  72.  
  73. }
Add Comment
Please, Sign In to add comment