isSMTP(); $mail->Host = 'server359.web-hosting.com'; $mail->SMTPAuth = true; $mail->Username = 'asistencia@facturahacienda.com'; $mail->Password = 'JJD-UQLKK(Vn'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; $mail->Port = 465; $mail->CharSet = 'UTF-8'; // Enable SMTP debugging (0 = off, 1 = client, 2 = client and server) $mail->SMTPDebug = 0; // Recipients $mail->setFrom('asistencia@facturahacienda.com', 'Sistema de Asistencia'); $mail->addAddress($destino); $mail->addReplyTo('asistencia@facturahacienda.com', 'No responder'); // Content $mail->isHTML(true); $mail->Subject = $asunto; // CSS for the email $emailStyles = ' '; // Email body with copy functionality $mail->Body = ' '.$emailStyles.'

'.$asunto.'

'.$tabla_html.'

Para copiar los datos al portapapeles:

'; // Plain text version for email clients that don't support HTML $mail->AltBody = "Informe de trabajo cotidiano\n\n" . "Por favor abra este mensaje en un cliente de correo que soporte HTML para ver la tabla completa.\n\n" . "Destinatario: $destino\n" . "Asunto: $asunto"; $mail->send(); echo json_encode(['success' => true, 'message' => '✅ Correo enviado exitosamente.']); } catch (Exception $e) { error_log("Mailer Error: " . $e->getMessage()); echo json_encode(['success' => false, 'message' => "❌ Error al enviar el correo: {$mail->ErrorInfo}"]); } } else { echo json_encode(['success' => false, 'message' => "⚠️ Correo inválido o tabla vacía."]); } } else { http_response_code(405); echo json_encode(['success' => false, 'message' => "Método no permitido."]); }