mail.php 2.54 KB
<?php



use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\Exception;

use PHPMailer\PHPMailer\SMTP;



require 'PHPMailer/src/Exception.php';

require 'PHPMailer/src/PHPMailer.php';

require 'PHPMailer/src/SMTP.php';



function enviarMail($id, $email, $dia, $hora, $nombre) {

    $id = ($id*50)*20;

    $mail = new PHPMailer(true);



    //Server settings

    $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output

    $mail->isSMTP();                                            // Send using SMTP

    $mail->Host       = 'smtp.gmail.com';                    // Set the SMTP server to send through

    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication

    $mail->Username   = 'turnos.gobierno@gmail.com';                     // SMTP username

    $mail->Password   = 'nvidia123';                               // SMTP password

    $mail->SMTPSecure = 'tls';         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged

    $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above



    //Recipients

    $mail->setFrom('turnos.gobierno@gmail.com', 'Gobierno de Catamarca - Turnos Online');

    $mail->addAddress($email);     // Add a recipient





    // Content

    $mail->isHTML(true);                                  // Set email format to HTML

    $mail->Subject = 'Confirme su turno';

    $mail->Body = '<img src="https://dgrpi.arca.gob.ar/turnos/img/logomail.png"><br>
        <h5>
        <ul>
            <li>Nombre: '.$nombre.'</li>
            <li>Día: '.$dia.'</li>
            <li>Hora: '.$hora.'</li>
        </ul>
        </h5>
        <h5>Para confirmar su turno haga clic en el siguiente enlace</h5><br>

        <table width="100%" cellspacing="0" cellpadding="0">

        <tr>

        <td>

        <table cellspacing="0" cellpadding="0">

        <tr>

        <td style="border-radius: 2px;" bgcolor="#214370">

        <a href="http://localhost/turnosapp/confirmar.php?code='.base64_encode($id).'" target="_blank" style="padding: 8px 12px; border: 1px solid #214370;border-radius: 2px;font-family: Helvetica, Arial, sans-serif;font-size: 14px; color: #ffffff;text-decoration: none;font-weight:bold;display: inline-block;">

        Confirmar turno          

        </a>

        </td>

        </tr>

        </table>

        </td>

        </tr>

        </table>';

    //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';



    $mail->send();

}

?>