Guest User

Untitled

a guest
Oct 30th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. /*
  3. Verifica autenticação SMTP conta de e-mail
  4. Requer instalar o PHPMailer
  5. composer require phpmailer/phpmailer
  6. */
  7.  
  8. use PHPMailer\PHPMailer\PHPMailer;
  9. use PHPMailer\PHPMailer\Exception;
  10.  
  11. require_once 'vendor/autoload.php';
  12.  
  13. function checkContaMail($server, $port, $email, $pass) {
  14. $mail = new PHPMailer();
  15.  
  16. $mail->SMTPOptions = array(
  17. 'ssl' => array(
  18. 'verify_peer' => false,
  19. 'verify_peer_name' => false,
  20. 'allow_self_signed' => true
  21. )
  22. );
  23.  
  24. $mail->isSMTP();
  25.  
  26. $mail->Host = $server;
  27. $mail->Port = $port;
  28. $mail->SMTPAuth = true; // turn on SMTP authentication
  29.  
  30. if($port == 587) {
  31. $mail->SMTPSecure = 'tls'; // port = 587
  32. }
  33. else if($port == 465) {
  34. $mail->SMTPSecure = 'ssl'; // port = 465
  35. }
  36. $mail->AuthType = '';
  37. $mail->Realm = '';
  38. $mail->Username = $email; // SMTP username
  39. $mail->Password = $pass; // SMTP password
  40. $mail->Timeout = 30;
  41.  
  42.  
  43. if($mail->smtpConnect()){
  44. $mail->smtpClose();
  45. return true;
  46. }
  47. else{
  48. return false;
  49. }
  50. }
Add Comment
Please, Sign In to add comment