use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; $mail = new PHPMailer(true); try { // ConfiguraciĆ³n del servidor SMTP $mail->isSMTP(); $mail->Host = 'smtp.tudominio.com'; // Servidor SMTP $mail->SMTPAuth = true; $mail->Username = 'tuemail@tudominio.com'; $mail->Password = 'tucontraseƱa'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; // Recipientes $mail->setFrom('tuemail@tudominio.com', 'Remitente'); $mail->addAddress($_POST['email']); // Destinatario // Contenido del correo $mail->isHTML(true); $mail->Subject = $_POST['subject']; $mail->Body = $_POST['message']; $mail->send(); echo 'Correo enviado exitosamente'; } catch (Exception $e) { echo "Error al enviar el correo: {$mail->ErrorInfo}"; }