diff --git a/wp-multi-ticket.php b/wp-multi-ticket.php index 53427f3..30ac2a8 100644 --- a/wp-multi-ticket.php +++ b/wp-multi-ticket.php @@ -3,7 +3,7 @@ * Plugin Name: WP Multi Ticket Pro * Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi-ticket * Description: Leistungsstarkes Ticket- und Support-System für WordPress mit Gast-Tickets, Admin-Antworten, CSV-Export, Dashboard-Widgets und integriertem Update-Management über Gitea. - * Version: 1.2 + * Version: 1.3 * Author: M_Viper * Author URI: https://m-viper.de * Requires at least: 6.7.2 @@ -17,8 +17,6 @@ * Support: https://t.me/M_Viper04 */ - - if ( ! defined( 'ABSPATH' ) ) exit; class WP_Multi_Ticket_Pro { @@ -47,6 +45,11 @@ class WP_Multi_Ticket_Pro { // Hook für Update-Benachrichtigung add_action( 'admin_notices', array( $this, 'check_plugin_updates' ) ); + // E-Mail-Konfiguration + add_action( 'phpmailer_init', array( $this, 'configure_phpmailer' ) ); + add_filter( 'wp_mail_from', array( $this, 'custom_wp_mail_from' ) ); + add_filter( 'wp_mail_from_name', array( $this, 'custom_wp_mail_from_name' ) ); + add_shortcode( 'wmt_form', array( $this, 'render_creation_form' ) ); add_shortcode( 'wmt_view', array( $this, 'render_ticket_view' ) ); add_shortcode( 'wmt_lookup', array( $this, 'render_lookup_form' ) ); @@ -60,7 +63,137 @@ class WP_Multi_Ticket_Pro { add_action( 'admin_init', array( $this, 'handle_csv_export' ) ); } - /** + /** + * FIX: Verbesserte Konfiguration für PHPMailer mit Server-Check + */ + public function configure_phpmailer( $phpmailer ) { + $smtp_enabled = get_option( 'wmt_smtp_enabled' ); + + if ( $smtp_enabled == '1' || $smtp_enabled === true ) { + $encryption = get_option( 'wmt_smtp_encryption', '' ); + + // Prüfen, ob OpenSSL geladen ist, wenn Verschlüsselung gefordert ist + if ( ( $encryption === 'tls' || $encryption === 'ssl' ) && ! extension_loaded('openssl') ) { + // Wir können hier keine Notices werfen, also loggen wir es + error_log('WMT SMTP Error: OpenSSL extension is missing, but encryption is set to ' . $encryption); + return; // Abbrechen, sonst crasht es + } + + $phpmailer->isSMTP(); + $phpmailer->Host = get_option( 'wmt_smtp_host', 'localhost' ); + $phpmailer->Port = get_option( 'wmt_smtp_port', 25 ); + + $phpmailer->SMTPSecure = ( $encryption === 'tls' ) ? 'tls' : ( ( $encryption === 'ssl' ) ? 'ssl' : '' ); + + $smtp_auth = get_option( 'wmt_smtp_auth' ); + $phpmailer->SMTPAuth = ( $smtp_auth == '1' || $smtp_auth === true ); + + if ( $phpmailer->SMTPAuth ) { + $phpmailer->Username = get_option( 'wmt_smtp_username', '' ); + $phpmailer->Password = get_option( 'wmt_smtp_password', '' ); + + // WICHTIG: Envelope Sender setzen (behebt "Sender address rejected") + $phpmailer->Sender = $phpmailer->Username; + } + + if ( get_option( 'wmt_smtp_debug', false ) ) { + $phpmailer->SMTPDebug = 3; + $phpmailer->Debugoutput = function($str, $level) { + error_log("SMTP Debug [Lvl $level]: $str"); + }; + } + } + + $phpmailer->CharSet = 'UTF-8'; + } + + /** + * Setzt die Absender-E-Mail + */ + public function custom_wp_mail_from( $original_email_address ) { + $custom_email = get_option( 'wmt_from_email', '' ); + return $custom_email ? $custom_email : $original_email_address; + } + + /** + * Setzt den Absender-Namen + */ + public function custom_wp_mail_from_name( $original_email_from ) { + $custom_name = get_option( 'wmt_from_name', '' ); + return $custom_name ? $custom_name : $original_email_from; + } + + /** + * Verbesserte E-Mail-Versand-Funktion mit Logging + */ + private function send_mail( $to, $subject, $message, $attachments = array() ) { + $html_message = ' + + +
+ + + + + +Kritischer Fehler: Ihre PHP-Installation hat die openssl Erweiterung nicht geladen. SMTP mit SSL/TLS kann nicht funktionieren. Bitte wenden Sie sich an Ihren Hoster.
| Zeit | +Empfänger | +Betreff | +Status | +
|---|---|---|---|
| + | + | + |
+
+
+ + + |
+
wp-content/debug.log.