Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Verifica autenticação SMTP conta de e-mail
- Requer instalar o PHPMailer
- composer require phpmailer/phpmailer
- */
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require_once 'vendor/autoload.php';
- function checkContaMail($server, $port, $email, $pass) {
- $mail = new PHPMailer();
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->isSMTP();
- $mail->Host = $server;
- $mail->Port = $port;
- $mail->SMTPAuth = true; // turn on SMTP authentication
- if($port == 587) {
- $mail->SMTPSecure = 'tls'; // port = 587
- }
- else if($port == 465) {
- $mail->SMTPSecure = 'ssl'; // port = 465
- }
- $mail->AuthType = '';
- $mail->Realm = '';
- $mail->Username = $email; // SMTP username
- $mail->Password = $pass; // SMTP password
- $mail->Timeout = 30;
- if($mail->smtpConnect()){
- $mail->smtpClose();
- return true;
- }
- else{
- return false;
- }
- }
Add Comment
Please, Sign In to add comment