Advertisement
Guest User

Untitled

a guest
Dec 29th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2.  
  3. class Mailer {
  4. //aqui é uma constatne para configurar usuario/ senha e nome que vai aparecer no titulo dp email
  5. const USERNAME = "";
  6. const PASSWORD = "";
  7. const NAME_FROM = "Hcode Store";
  8. private $mail;
  9. // No contrutor recebemos 3 paramentros que toAddess = email para vou mardar, toName = nome do cara, subject = assunto
  10. public function __construct($toAddress,$toName,$subjec)
  11. {
  12. utf8_encode($toAddress);
  13. utf8_encode($toName);
  14. utf8_encode($subject);
  15.  
  16. echo "<h1>".(extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."</h1>"."\n";
  17.  
  18. $this->mail = new \PHPMailer();
  19. $this->mail->WordWrap = 50;
  20. $this->mail->isHTML(true);
  21. $this->mail->SMTPSecure = 'ssl';
  22. $this->mail->isSMTP();
  23. $this->mail->SMTPDebug = 0;
  24. $this->mail->Host = 'smtp.gmail.com';
  25. $this->mail->Port = 465;
  26. $this->mail->SMTPAuth = true;
  27. $this->mail->SMTPOptions = array(
  28. 'ssl' => array(
  29. 'verify_peer' => false,
  30. 'verify_peer_name' => false,
  31. 'allow_self_signed' => false
  32. )
  33. );
  34. $this->mail->Username = Mailer::USERNAME;
  35. $this->mail->Password = Mailer::PASSWORD;
  36. $this->mail->setFrom(Mailer::USERNAME,Mailer::NAME_FROM);
  37.  
  38. $this->mail->addAddress($toAddress,$toName);
  39. $this->mail->Subject = ($subject);
  40. $this->mail->msgHTML($html);
  41. $this->mail->AltBody ="Alternativo";
  42.  
  43. }
  44. public function send()
  45. {
  46.  
  47. return $this->mail->send();
  48. }
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement