T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/soundstudiopro.com/public_html/config/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/public_html/config/email.php
<?php
// Email configuration for SoundStudioPro

// Load Composer autoloader when available so PHPMailer classes can be used
$vendorAutoload = __DIR__ . '/../vendor/autoload.php';
if (file_exists($vendorAutoload)) {
    require_once $vendorAutoload;
}

// Load translation system
require_once __DIR__ . '/../includes/translations.php';

// SMTP Configuration
// Production SMTP settings for soundstudiopro.com
define('SMTP_HOST', 'mail.soundstudiopro.com');
define('SMTP_PORT', 587);
define('SMTP_USERNAME', 'confirmation@soundstudiopro.com');
define('SMTP_PASSWORD', 'C3nGG9e5Dw7NRXuXLxwq');
define('SMTP_FROM_EMAIL', 'confirmation@soundstudiopro.com');
define('SMTP_FROM_NAME', 'SoundStudioPro');

// Email configuration - will fallback to mail() if PHPMailer not available

// Email configuration - will fallback to mail() if PHPMailer not available

// Email sending function using PHPMailer
function sendEmail($to_email, $to_name, $subject, $html_body, $text_body = null, $email_type = 'general', $user_id = null, $order_id = null) {
    // Log email attempt to database
    $pdo = getDBConnection();
    $log_id = null;
    
    if ($pdo) {
        try {
            $stmt = $pdo->prepare("
                INSERT INTO email_logs (recipient_email, recipient_name, subject, email_type, status, user_id, order_id)
                VALUES (?, ?, ?, ?, 'pending', ?, ?)
            ");
            $stmt->execute([$to_email, $to_name, $subject, $email_type, $user_id, $order_id]);
            $log_id = $pdo->lastInsertId();
        } catch (Exception $e) {
            error_log("Failed to log email to database: " . $e->getMessage());
        }
    }
    
    // Check if PHPMailer is available
    if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) {
        // Fallback to basic mail() function
        $subject_encoded = '=?UTF-8?B?' . base64_encode($subject) . '?=';
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        $headers .= "From: " . SMTP_FROM_NAME . " <" . SMTP_FROM_EMAIL . ">" . "\r\n";
        
        $result = mail($to_email, $subject_encoded, $html_body, $headers);
        
        // Update log with result
        if ($pdo && $log_id) {
            try {
                $stmt = $pdo->prepare("
                    UPDATE email_logs SET status = ?, error_message = ? WHERE id = ?
                ");
                $stmt->execute([$result ? 'sent' : 'failed', $result ? null : 'mail() function failed', $log_id]);
            } catch (Exception $e) {
                error_log("Failed to update email log: " . $e->getMessage());
            }
        }
        
        return $result;
    }
    
    try {
        $mail = new PHPMailer\PHPMailer\PHPMailer(true);
        
        // Server settings
        $mail->isSMTP();
        $mail->Host = SMTP_HOST;
        $mail->SMTPAuth = true;
        $mail->Username = SMTP_USERNAME;
        $mail->Password = SMTP_PASSWORD;
        $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
        $mail->Port = SMTP_PORT;
        
        // Recipients
        $mail->setFrom(SMTP_FROM_EMAIL, SMTP_FROM_NAME);
        $mail->addAddress($to_email, $to_name);
        
        // Content - Set UTF-8 encoding
        $mail->CharSet = 'UTF-8';
        $mail->Encoding = 'base64';
        $mail->isHTML(true);
        $mail->Subject = $subject;
        $mail->Body = $html_body;
        
        if ($text_body) {
            $mail->AltBody = $text_body;
        }
        
        $mail->send();
        error_log("Email sent successfully to: $to_email");
        
        // Update log with success
        if ($pdo && $log_id) {
            try {
                $stmt = $pdo->prepare("UPDATE email_logs SET status = 'sent' WHERE id = ?");
                $stmt->execute([$log_id]);
            } catch (Exception $e) {
                error_log("Failed to update email log: " . $e->getMessage());
            }
        }
        
        return true;
        
    } catch (Exception $e) {
        // Get error message from PHPMailer if available, otherwise use exception message
        $error_message = (isset($mail) && property_exists($mail, 'ErrorInfo')) ? $mail->ErrorInfo : $e->getMessage();
        error_log("Email sending failed to {$to_email}: " . $error_message);
        error_log("Exception details: " . $e->getMessage() . " | Trace: " . $e->getTraceAsString());
        
        // Update log with failure
        if ($pdo && $log_id) {
            try {
                $stmt = $pdo->prepare("
                    UPDATE email_logs SET status = 'failed', error_message = ? WHERE id = ?
                ");
                $stmt->execute([$error_message, $log_id]);
            } catch (Exception $db_error) {
                error_log("Failed to update email log: " . $db_error->getMessage());
            }
        }
        
        return false;
    }
}

// Generate order confirmation email
function generateOrderConfirmationEmail($user_name, $order_details, $billing_address) {
    // Get user language from session
    $lang = getCurrentLanguage();
    
    // Format order date based on language
    if ($lang === 'fr') {
        setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'french');
        $order_date = strftime('%e %B %Y Ă  %H:%M', time());
    } else {
        $order_date = date('F j, Y \a\t g:i A');
    }
    
    $order_number = 'SSP-' . date('Ymd') . '-' . strtoupper(substr(md5(uniqid()), 0, 8));
    $total_amount = number_format($order_details['total_amount'] / 100, 2);
    
    // Build order items HTML with full details for all types
    $items_html = '';
    $has_credits = false;
    $has_tracks = false;
    $has_tickets = false;
    
    foreach ($order_details['cart_summary'] as $item) {
        $item_price = number_format($item['amount'] / 100, 2);
        $item_description = '';
        
        if ($item['type'] === 'credit') {
            $has_credits = true;
            $credits_count = isset($item['credits']) ? $item['credits'] : 0;
            $item_description = htmlspecialchars($item['name'] ?? t('email.credit_package')) . 
                               ' (' . $credits_count . ' ' . t('email.credits') . ')';
        } elseif ($item['type'] === 'track') {
            $has_tracks = true;
            $artist_name = htmlspecialchars($item['artist'] ?? $item['artist_name'] ?? t('checkout.unknown_artist'));
            $track_title = htmlspecialchars($item['title'] ?? 'Untitled Track');
            $item_description = $track_title . ' ' . t('email.by_artist') . ' ' . $artist_name;
        } elseif ($item['type'] === 'ticket') {
            $has_tickets = true;
            $event_title = htmlspecialchars($item['event_title'] ?? t('email.event_ticket'));
            $ticket_word = ($item['quantity'] > 1) ? t('email.tickets') : t('email.ticket');
            $is_free = isset($item['is_free']) && $item['is_free'];
            $item_description = $event_title . ' (' . $item['quantity'] . ' ' . $ticket_word . ')';
            if ($is_free) {
                $item_price = t('email.free');
            }
        }
        
        $items_html .= '
                                        <tr>
                                            <td style="padding: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); color: #ffffff; background-color: #1a1a1a;">' . $item_description . '</td>
                                            <td style="padding: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); text-align: center; color: #ffffff; background-color: #1a1a1a;">' . $item['quantity'] . '</td>
                                            <td style="padding: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); text-align: right; color: #ffffff; background-color: #1a1a1a;">' . 
                                            ($item['type'] === 'ticket' && isset($item['is_free']) && $item['is_free'] ? t('email.free') : '$' . $item_price) . '</td>
                                        </tr>';
    }
    
    $html = '
    <!DOCTYPE html>
    <html lang="' . $lang . '">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>' . t('email.order_confirmation') . ' - SoundStudioPro</title>
    </head>
    <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0a0a0a;">
        <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #0a0a0a;">
            <tr>
                <td align="center" style="padding: 20px 0;">
                    <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="background-color: #1a1a1a; border-radius: 12px; overflow: hidden;">
                        <!-- Header -->
                        <tr>
                            <td bgcolor="#667eea" style="background-color: #667eea; padding: 40px 30px; text-align: center;">
                                <h1 style="margin: 0 0 10px 0; font-size: 2.5rem; font-weight: bold; color: #ffffff !important;">đŸŽ” SoundStudioPro</h1>
                                <h2 style="margin: 0 0 20px 0; font-size: 1.5rem; font-weight: 300; color: #ffffff !important;">' . t('email.order_confirmation') . '</h2>
                                <div style="background-color: rgba(255, 255, 255, 0.25); color: #ffffff !important; padding: 12px 24px; border-radius: 8px; display: inline-block; margin: 10px 0; font-weight: bold; font-size: 1.1rem;">' . t('email.order_confirmation') . ' #' . htmlspecialchars($order_number) . '</div>
                                <p style="margin: 15px 0 0 0; color: #ffffff !important;">' . t('email.thank_you_purchase') . '</p>
                            </td>
                        </tr>
                        <!-- Content -->
                        <tr>
                            <td style="background-color: #1a1a1a; padding: 40px 30px;">
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.dear') . ' ' . htmlspecialchars($user_name) . ',</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.order_confirmed') . '</p>
                                
                                <h3 style="margin: 30px 0 15px 0; color: #667eea; font-size: 1.3rem; font-weight: bold;">' . t('email.order_details') . '</h3>
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 20px 0; background-color: #1a1a1a;">
                                    <thead>
                                        <tr>
                                            <th bgcolor="#667eea" style="background-color: #667eea; color: #ffffff !important; padding: 15px; text-align: left; font-weight: 600;">' . t('email.item') . '</th>
                                            <th bgcolor="#667eea" style="background-color: #667eea; color: #ffffff !important; padding: 15px; text-align: center; font-weight: 600;">' . t('email.quantity') . '</th>
                                            <th bgcolor="#667eea" style="background-color: #667eea; color: #ffffff !important; padding: 15px; text-align: right; font-weight: 600;">' . t('email.price') . '</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        ' . $items_html . '
                                        <tr style="background-color: rgba(102, 126, 234, 0.1);">
                                            <td colspan="2" style="padding: 15px; text-align: right; font-weight: bold; color: #667eea; font-size: 1.1rem;">' . t('email.total') . ':</td>
                                            <td style="padding: 15px; text-align: right; font-weight: bold; color: #667eea; font-size: 1.1rem;">$' . htmlspecialchars($total_amount) . '</td>
                                        </tr>
                                    </tbody>
                                </table>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #1a1a1a; padding: 25px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #667eea;">
                                    <tr>
                                        <td>
                                            <h4 style="margin: 0 0 15px 0; color: #667eea; font-size: 1.1rem; font-weight: bold;">' . t('email.billing_information') . '</h4>
                                            <p style="margin: 10px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.name') . ':</strong> ' . htmlspecialchars($billing_address['billing_first_name'] . ' ' . $billing_address['billing_last_name']) . '</p>
                                            <p style="margin: 10px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.email') . ':</strong> ' . htmlspecialchars($billing_address['billing_email']) . '</p>
                                            <p style="margin: 10px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.address') . ':</strong><br>
                                            ' . htmlspecialchars($billing_address['billing_address']) . '<br>
                                            ' . htmlspecialchars($billing_address['billing_city']) . ', ' . htmlspecialchars($billing_address['billing_state']) . ' ' . htmlspecialchars($billing_address['billing_zip']) . '<br>
                                            ' . htmlspecialchars($billing_address['billing_country']) . '</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <h3 style="margin: 30px 0 15px 0; color: #667eea; font-size: 1.3rem; font-weight: bold;">' . t('email.whats_next') . '</h3>';
    
    // Add specific next steps based on what was purchased
    if ($has_credits) {
        $html .= '
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.credits_added') . ':</strong> ' . t('email.credits_added_desc') . '</p>
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.credits_start_creating') . '</p>';
    }
    
    if ($has_tracks) {
        $html .= '
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.tracks_purchased') . ':</strong> ' . t('email.tracks_purchased_desc') . '</p>
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.tracks_access') . '</p>';
    }
    
    if ($has_tickets) {
        $html .= '
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.tickets_purchased') . ':</strong> ' . t('email.tickets_purchased_desc') . '</p>
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.tickets_access') . '</p>';
    }
    
    // Build action buttons based on what was purchased
    $buttons_html = '<a href="https://soundstudiopro.com/dashboard.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">' . t('email.go_to_dashboard') . '</a>';
    if ($has_credits) {
        $buttons_html .= '<a href="https://soundstudiopro.com/credits.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">' . t('email.view_credits') . '</a>';
    }
    if ($has_tickets) {
        $buttons_html .= '<a href="https://soundstudiopro.com/my_tickets.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">' . t('email.view_tickets') . '</a>';
    }
    
    $html .= '
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 30px 0;">
                                    <tr>
                                        <td align="center">
                                            ' . $buttons_html . '
                                        </td>
                                    </tr>
                                </table>
                                
                                <h3 style="margin: 30px 0 15px 0; color: #667eea; font-size: 1.3rem; font-weight: bold;">' . t('email.need_help') . '</h3>
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.need_help_desc') . '</p>
                                <ul style="margin: 15px 0; padding-left: 25px; color: #a0aec0; font-size: 16px; line-height: 1.6;">
                                    <li style="margin: 8px 0;">' . t('email.support_email') . ': <a href="mailto:support@soundstudiopro.com" style="color: #667eea; text-decoration: none;">support@soundstudiopro.com</a></li>
                                    <li style="margin: 8px 0;">' . t('email.support_website') . ': <a href="https://soundstudiopro.com/support" style="color: #667eea; text-decoration: none;">soundstudiopro.com/support</a></li>
                                </ul>
                                
                                <p style="margin: 20px 0 10px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.order_date') . ':</strong> ' . htmlspecialchars($order_date) . '</p>
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;"><strong style="color: #ffffff;">' . t('email.payment_method') . ':</strong> ' . t('email.payment_method_stripe') . '</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top: 40px; padding-top: 30px; border-top: 1px solid rgba(255, 255, 255, 0.1);">
                                    <tr>
                                        <td align="center" style="padding: 20px 0;">
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">' . t('email.thank_you_choosing') . '</p>
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">&copy; ' . date('Y') . ' SoundStudioPro. ' . t('email.all_rights_reserved') . '</p>
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">' . t('email.sent_to') . ' ' . htmlspecialchars($billing_address['billing_email']) . '</p>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
    </html>';
    
    // Build text version of email
    $text = t('email.order_confirmation') . " - SoundStudioPro\n\n";
    $text .= t('email.dear') . " $user_name,\n\n";
    $text .= t('email.order_confirmed') . "\n\n";
    $text .= t('email.order_confirmation') . " #$order_number\n";
    $text .= t('email.order_date') . ": $order_date\n";
    $text .= t('email.total') . ": \$$total_amount\n\n";
    
    $text .= t('email.order_details') . ":\n";
    foreach ($order_details['cart_summary'] as $item) {
        $item_price = number_format($item['amount'] / 100, 2);
        if ($item['type'] === 'credit') {
            $credits_count = isset($item['credits']) ? $item['credits'] : 0;
            $text .= "- " . ($item['name'] ?? t('email.credit_package')) . " (" . $credits_count . " " . t('email.credits') . ") - Qty: " . $item['quantity'] . " - \$$item_price\n";
        } elseif ($item['type'] === 'track') {
            $artist_name = $item['artist'] ?? $item['artist_name'] ?? t('checkout.unknown_artist');
            $track_title = $item['title'] ?? 'Untitled Track';
            $text .= "- $track_title " . t('email.by_artist') . " $artist_name - Qty: " . $item['quantity'] . " - \$$item_price\n";
        } elseif ($item['type'] === 'ticket') {
            $event_title = $item['event_title'] ?? t('email.event_ticket');
            $ticket_word = ($item['quantity'] > 1) ? t('email.tickets') : t('email.ticket');
            $is_free = isset($item['is_free']) && $item['is_free'];
            $price_text = $is_free ? t('email.free') : "\$$item_price";
            $text .= "- $event_title ($ticket_word) - Qty: " . $item['quantity'] . " - $price_text\n";
        }
    }
    
    $text .= "\n" . t('email.billing_information') . ":\n";
    $text .= t('email.name') . ": " . ($billing_address['billing_first_name'] . ' ' . $billing_address['billing_last_name']) . "\n";
    $text .= t('email.email') . ": " . $billing_address['billing_email'] . "\n";
    $text .= t('email.address') . ": " . $billing_address['billing_address'] . ", " . $billing_address['billing_city'] . ", " . $billing_address['billing_state'] . " " . $billing_address['billing_zip'] . ", " . $billing_address['billing_country'] . "\n\n";
    
    if ($has_credits) {
        $text .= t('email.credits_added') . ": " . t('email.credits_added_desc') . "\n";
    }
    if ($has_tracks) {
        $text .= t('email.tracks_purchased') . ": " . t('email.tracks_purchased_desc') . "\n";
    }
    if ($has_tickets) {
        $text .= t('email.tickets_purchased') . ": " . t('email.tickets_purchased_desc') . "\n";
    }
    
    $text .= "\n" . t('email.need_help') . "\n";
    $text .= t('email.support_email') . ": support@soundstudiopro.com\n";
    $text .= t('email.support_website') . ": https://soundstudiopro.com/support\n\n";
    $text .= t('email.thank_you_choosing') . "\n";
    $text .= "© " . date('Y') . " SoundStudioPro. " . t('email.all_rights_reserved');
    
    return [
        'html' => $html,
        'text' => $text,
        'subject' => t('email.order_confirmation') . " - SoundStudioPro (" . t('email.order_confirmation') . " #$order_number)"
    ];
}

// Generate invoice email for track purchases
function generateInvoiceEmail($user_name, $user_email, $purchase_data) {
    require_once __DIR__ . '/database.php';
    $pdo = getDBConnection();
    
    // Extract purchase data
    $purchase_id = $purchase_data['purchase_id'] ?? null;
    $track_id = $purchase_data['track_id'] ?? null;
    $track_ids = $purchase_data['track_ids'] ?? ($track_id ? [$track_id] : []);
    $price_paid = $purchase_data['price_paid'] ?? 0;
    $total_amount = $purchase_data['total_amount'] ?? $price_paid;
    $payment_method = $purchase_data['payment_method'] ?? 'stripe';
    $payment_intent_id = $purchase_data['payment_intent_id'] ?? null;
    $purchase_date = $purchase_data['purchase_date'] ?? date('Y-m-d H:i:s');
    $billing_address = $purchase_data['billing_address'] ?? [];
    
    // Generate invoice number
    $invoice_number = 'INV-' . date('Ymd') . '-' . strtoupper(substr(md5(uniqid() . $purchase_id), 0, 8));
    
    // Get track details
    $tracks = [];
    if (!empty($track_ids) && $pdo) {
        $placeholders = str_repeat('?,', count($track_ids) - 1) . '?';
        $stmt = $pdo->prepare("
            SELECT 
                mt.id,
                mt.title,
                mt.price,
                mt.audio_url,
                mt.duration,
                u.name as artist_name,
                u.id as artist_id
            FROM music_tracks mt
            JOIN users u ON mt.user_id = u.id
            WHERE mt.id IN ($placeholders)
        ");
        $stmt->execute($track_ids);
        $tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
    }
    
    // Format purchase date
    $formatted_date = date('F j, Y \a\t g:i A', strtotime($purchase_date));
    
    // Build track items HTML
    $items_html = '';
    $subtotal = 0;
    foreach ($tracks as $track) {
        $track_price = floatval($track['price']);
        $subtotal += $track_price;
        $duration = $track['duration'] ? gmdate("i:s", $track['duration']) : 'N/A';
        $track_url = 'https://soundstudiopro.com/track.php?id=' . $track['id'];
        
        $items_html .= '
        <tr style="border-bottom: 1px solid #e2e8f0;">
            <td style="padding: 15px; vertical-align: top;">
                <strong style="color: #667eea; font-size: 16px;">' . htmlspecialchars($track['title']) . '</strong><br>
                <span style="color: #666; font-size: 14px;">by ' . htmlspecialchars($track['artist_name']) . '</span><br>
                <span style="color: #999; font-size: 12px;">Duration: ' . $duration . '</span>
            </td>
            <td style="padding: 15px; text-align: center; vertical-align: top;">1</td>
            <td style="padding: 15px; text-align: right; vertical-align: top;">$' . number_format($track_price, 2) . '</td>
            <td style="padding: 15px; text-align: right; vertical-align: top;">$' . number_format($track_price, 2) . '</td>
        </tr>';
    }
    
    // Calculate totals
    $tax = 0; // No tax for now
    $total = $subtotal + $tax;
    
    // Format billing address
    $billing_html = '';
    if (!empty($billing_address)) {
        $billing_html = '
        <div style="background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #667eea;">
            <h4 style="color: #667eea; margin: 0 0 15px 0;">Billing Information</h4>
            <p style="margin: 5px 0;"><strong>Name:</strong> ' . htmlspecialchars(($billing_address['billing_first_name'] ?? '') . ' ' . ($billing_address['billing_last_name'] ?? '')) . '</p>
            <p style="margin: 5px 0;"><strong>Email:</strong> ' . htmlspecialchars($billing_address['billing_email'] ?? $user_email) . '</p>';
        
        if (!empty($billing_address['billing_address'])) {
            $billing_html .= '
            <p style="margin: 5px 0;"><strong>Address:</strong><br>
            ' . htmlspecialchars($billing_address['billing_address']) . '<br>
            ' . htmlspecialchars($billing_address['billing_city'] ?? '') . ', ' . htmlspecialchars($billing_address['billing_state'] ?? '') . ' ' . htmlspecialchars($billing_address['billing_zip'] ?? '') . '<br>
            ' . htmlspecialchars($billing_address['billing_country'] ?? '') . '</p>';
        }
        $billing_html .= '</div>';
    }
    
    $html = '
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Invoice - SoundStudioPro</title>
        <style>
            body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; background: #f5f5f5; }
            .container { max-width: 800px; margin: 20px auto; background: white; box-shadow: 0 0 20px rgba(0,0,0,0.1); }
            .header { background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 40px; text-align: center; }
            .invoice-header { display: flex; justify-content: space-between; align-items: center; padding: 30px 40px; background: #f8f9fa; border-bottom: 2px solid #e2e8f0; }
            .invoice-number { font-size: 24px; font-weight: bold; color: #667eea; }
            .invoice-date { color: #666; }
            .content { padding: 40px; }
            .company-info { margin-bottom: 30px; }
            .invoice-table { width: 100%; border-collapse: collapse; margin: 30px 0; }
            .invoice-table th { background: #667eea; color: white; padding: 15px; text-align: left; font-weight: bold; }
            .invoice-table td { padding: 15px; border-bottom: 1px solid #e2e8f0; }
            .invoice-table tr:last-child td { border-bottom: none; }
            .text-right { text-align: right; }
            .text-center { text-align: center; }
            .total-section { background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 30px 0; }
            .total-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #e2e8f0; }
            .total-row:last-child { border-bottom: none; font-weight: bold; font-size: 18px; color: #667eea; }
            .footer { background: #1a1a1a; color: white; padding: 30px 40px; text-align: center; }
            .download-btn { display: inline-block; background: #667eea; color: white; padding: 12px 24px; text-decoration: none; border-radius: 5px; margin: 10px 5px; }
            .payment-info { background: #e8f5e9; padding: 15px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #4caf50; }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="header">
                <h1 style="margin: 0; font-size: 2.5rem;">đŸŽ” SoundStudioPro</h1>
                <p style="margin: 10px 0 0 0; font-size: 18px;">Purchase Invoice</p>
            </div>
            
            <div class="invoice-header">
                <div>
                    <div class="invoice-number">Invoice #' . $invoice_number . '</div>
                    <div class="invoice-date">Date: ' . $formatted_date . '</div>
                </div>
                <div style="text-align: right;">
                    <div style="font-size: 14px; color: #666;">SoundStudioPro</div>
                    <div style="font-size: 12px; color: #999;">confirmation@soundstudiopro.com</div>
                </div>
            </div>
            
            <div class="content">
                <div class="company-info">
                    <h3 style="color: #667eea; margin: 0 0 10px 0;">Bill To:</h3>
                    <p style="margin: 5px 0; font-size: 16px;"><strong>' . htmlspecialchars($user_name) . '</strong></p>
                    <p style="margin: 5px 0; color: #666;">' . htmlspecialchars($user_email) . '</p>
                </div>
                
                <h3 style="color: #667eea; margin: 30px 0 15px 0;">Items Purchased</h3>
                <table class="invoice-table">
                    <thead>
                        <tr>
                            <th>Track</th>
                            <th class="text-center">Quantity</th>
                            <th class="text-right">Unit Price</th>
                            <th class="text-right">Total</th>
                        </tr>
                    </thead>
                    <tbody>
                        ' . $items_html . '
                    </tbody>
                </table>
                
                <div class="total-section">
                    <div class="total-row">
                        <span>Subtotal:</span>
                        <span>$' . number_format($subtotal, 2) . '</span>
                    </div>
                    <div class="total-row">
                        <span>Tax:</span>
                        <span>$' . number_format($tax, 2) . '</span>
                    </div>
                    <div class="total-row">
                        <span>Total:</span>
                        <span>$' . number_format($total, 2) . '</span>
                    </div>
                </div>
                
                <div class="payment-info">
                    <h4 style="margin: 0 0 10px 0; color: #2e7d32;">✅ Payment Confirmed</h4>
                    <p style="margin: 5px 0;"><strong>Payment Method:</strong> ' . ucfirst($payment_method) . '</p>';
    
    if ($payment_intent_id) {
        $html .= '<p style="margin: 5px 0;"><strong>Transaction ID:</strong> ' . htmlspecialchars($payment_intent_id) . '</p>';
    }
    
    $html .= '
                    <p style="margin: 5px 0;"><strong>Status:</strong> <span style="color: #4caf50; font-weight: bold;">Paid</span></p>
                </div>
                
                ' . $billing_html . '
                
                <h3 style="color: #667eea; margin: 30px 0 15px 0;">Access Your Purchases</h3>
                <p>Your purchased tracks are now available in your library. You can download them anytime:</p>
                <div style="text-align: center; margin: 30px 0;">
                    <a href="https://soundstudiopro.com/my_purchases.php" class="download-btn">View My Purchases</a>
                    <a href="https://soundstudiopro.com/library.php" class="download-btn">Go to Library</a>
                </div>
                
                <div style="background: #fff3cd; padding: 15px; border-radius: 8px; margin: 30px 0; border-left: 4px solid #ffc107;">
                    <h4 style="margin: 0 0 10px 0; color: #856404;">📋 Important Information</h4>
                    <ul style="margin: 0; padding-left: 20px; color: #856404;">
                        <li>This invoice serves as your receipt for this purchase</li>
                        <li>All purchased tracks are available for unlimited downloads</li>
                        <li>Keep this email for your records</li>
                        <li>For support, contact us at support@soundstudiopro.com</li>
                    </ul>
                </div>
            </div>
            
            <div class="footer">
                <p style="margin: 0 0 10px 0; font-size: 16px;">Thank you for your purchase!</p>
                <p style="margin: 0; font-size: 14px; color: #a0aec0;">
                    © ' . date('Y') . ' SoundStudioPro. All rights reserved.<br>
                    This is an automated invoice. Please save this email for your records.
                </p>
            </div>
        </div>
    </body>
    </html>';
    
    $text = "INVOICE - SoundStudioPro\n\n";
    $text .= "Invoice #: $invoice_number\n";
    $text .= "Date: $formatted_date\n\n";
    $text .= "Bill To: $user_name\n";
    $text .= "Email: $user_email\n\n";
    $text .= "Items Purchased:\n";
    foreach ($tracks as $track) {
        $text .= "- " . $track['title'] . " by " . $track['artist_name'] . " - $" . number_format($track['price'], 2) . "\n";
    }
    $text .= "\nSubtotal: $" . number_format($subtotal, 2) . "\n";
    $text .= "Tax: $" . number_format($tax, 2) . "\n";
    $text .= "Total: $" . number_format($total, 2) . "\n\n";
    $text .= "Payment Method: " . ucfirst($payment_method) . "\n";
    if ($payment_intent_id) {
        $text .= "Transaction ID: $payment_intent_id\n";
    }
    $text .= "Status: Paid\n\n";
    $text .= "Access your purchases: https://soundstudiopro.com/my_purchases.php\n\n";
    $text .= "Thank you for your purchase!\n";
    $text .= "© " . date('Y') . " SoundStudioPro. All rights reserved.";
    
    return [
        'html' => $html,
        'text' => $text,
        'subject' => "Invoice #$invoice_number - SoundStudioPro Purchase"
    ];
}

// Generate welcome email for new user registration
function generateWelcomeEmail($user_name, $user_email, $credits = 0, $password = null) {
    // Get user language from session
    $lang = getCurrentLanguage();
    
    $html = '
    <!DOCTYPE html>
    <html lang="' . $lang . '">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>' . t('email.welcome.title') . ' - SoundStudioPro</title>
    </head>
    <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0a0a0a;">
        <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #0a0a0a;">
            <tr>
                <td align="center" style="padding: 20px 0;">
                    <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="background-color: #1a1a1a; border-radius: 12px; overflow: hidden;">
                        <!-- Header -->
                        <tr>
                            <td bgcolor="#667eea" style="background-color: #667eea; padding: 40px 30px; text-align: center;">
                                <h1 style="margin: 0 0 10px 0; font-size: 2.5rem; font-weight: bold; color: #ffffff !important;">đŸŽ” SoundStudioPro</h1>
                                <div style="background-color: rgba(255, 255, 255, 0.25); color: #ffffff !important; padding: 12px 24px; border-radius: 8px; display: inline-block; margin: 10px 0; font-weight: bold; font-size: 1.1rem;">' . t('email.welcome.badge') . '</div>
                                <p style="margin: 15px 0 0 0; color: #ffffff !important; font-size: 18px;">' . t('email.welcome.subtitle') . '</p>
                            </td>
                        </tr>
                        <!-- Content -->
                        <tr>
                            <td style="background-color: #1a1a1a; padding: 40px 30px;">
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.dear') . ' ' . htmlspecialchars($user_name) . ',</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(102, 126, 234, 0.1); padding: 30px; border-radius: 15px; margin: 30px 0; text-align: center;">
                                    <tr>
                                        <td>
                                            <h3 style="margin: 0 0 15px 0; font-size: 24px; color: #ffffff !important;">' . t('email.welcome.creative_sanctuary') . '</h3>
                                            <p style="font-style: italic; font-size: 18px; margin: 20px 0; color: #ffffff !important;">"' . t('email.welcome.quote') . '"</p>
                                            <p style="margin: 0; font-size: 16px; color: #ffffff !important;">' . t('email.welcome.community') . '</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">' . t('email.welcome.thrilled') . '</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(79, 172, 254, 0.2); padding: 25px; border-radius: 12px; margin: 25px 0; text-align: center;">
                                    <tr>
                                        <td>
                                            <h3 style="margin: 0 0 10px 0; color: #ffffff !important;">' . t('email.welcome.gift') . '</h3>
                                            <p style="margin: 0; font-size: 18px; color: #ffffff !important;"><strong>' . $credits . ' ' . t('email.credits') . '</strong> ' . t('email.welcome.credits_waiting') . '</p>
                                            <p style="margin: 10px 0 0 0; font-size: 14px; color: #ffffff !important;">' . t('email.welcome.start_creating') . '</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                ' . ($password ? '
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(34, 197, 94, 0.1); padding: 25px; border-radius: 12px; margin: 25px 0; border-left: 4px solid #22c55e;">
                                    <tr>
                                        <td>
                                            <h4 style="color: #22c55e; margin: 0 0 15px 0; font-size: 18px; font-weight: bold;">' . t('email.welcome.login_credentials') . '</h4>
                                            <p style="margin: 0 0 15px 0; font-size: 16px; color: #a0aec0;">' . t('email.welcome.save_credentials') . '</p>
                                            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #1a1a1a; padding: 20px; border-radius: 8px;">
                                                <tr>
                                                    <td style="padding: 10px 0;">
                                                        <strong style="color: #667eea; font-size: 16px;">' . t('email.welcome.website') . ':</strong>
                                                        <p style="margin: 5px 0 0 0; font-size: 16px; color: #ffffff;">https://soundstudiopro.com</p>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="padding: 10px 0;">
                                                        <strong style="color: #667eea; font-size: 16px;">' . t('email.email') . ':</strong>
                                                        <p style="margin: 5px 0 0 0; font-size: 16px; color: #ffffff; font-family: monospace;">' . htmlspecialchars($user_email) . '</p>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="padding: 10px 0;">
                                                        <strong style="color: #667eea; font-size: 16px;">' . t('login.password') . ':</strong>
                                                        <p style="margin: 5px 0 0 0; font-size: 16px; color: #ffffff; font-family: monospace;">' . htmlspecialchars($password) . '</p>
                                                    </td>
                                                </tr>
                                            </table>
                                            <p style="margin: 15px 0 0 0; font-size: 14px; color: #718096; font-style: italic;">' . t('email.welcome.password_tip') . '</p>
                                        </td>
                                    </tr>
                                </table>
                                ' : '') . '
                                
                                <h3 style="margin: 30px 0 15px 0; color: #667eea; font-size: 1.3rem; font-weight: bold; text-align: center;">' . t('email.welcome.what_awaits') . '</h3>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 20px 0;">
                                    <tr>
                                        <td style="padding: 15px; background-color: rgba(26, 26, 26, 0.9); border-left: 4px solid #667eea; border-radius: 8px; margin-bottom: 15px;">
                                            <h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px; font-weight: bold;">' . t('email.welcome.ai_creation') . '</h4>
                                            <p style="margin: 0; font-size: 15px; line-height: 1.5; color: #a0aec0;">' . t('email.welcome.ai_creation_desc') . '</p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 15px; background-color: rgba(26, 26, 26, 0.9); border-left: 4px solid #667eea; border-radius: 8px; margin-bottom: 15px;">
                                            <h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px; font-weight: bold;">' . t('email.welcome.premium_library') . '</h4>
                                            <p style="margin: 0; font-size: 15px; line-height: 1.5; color: #a0aec0;">' . t('email.welcome.premium_library_desc') . '</p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 15px; background-color: rgba(26, 26, 26, 0.9); border-left: 4px solid #667eea; border-radius: 8px; margin-bottom: 15px;">
                                            <h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px; font-weight: bold;">' . t('email.welcome.vibrant_community') . '</h4>
                                            <p style="margin: 0; font-size: 15px; line-height: 1.5; color: #a0aec0;">' . t('email.welcome.vibrant_community_desc') . '</p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 15px; background-color: rgba(26, 26, 26, 0.9); border-left: 4px solid #667eea; border-radius: 8px;">
                                            <h4 style="color: #667eea; margin: 0 0 10px 0; font-size: 16px; font-weight: bold;">' . t('email.welcome.instant_access') . '</h4>
                                            <p style="margin: 0; font-size: 15px; line-height: 1.5; color: #a0aec0;">' . t('email.welcome.instant_access_desc') . '</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 30px 0;">
                                    <tr>
                                        <td align="center">
                                            <a href="https://soundstudiopro.com/dashboard.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">' . t('email.go_to_dashboard') . '</a>
                                            <a href="https://soundstudiopro.com/credits.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">' . t('email.view_credits') . '</a>
                                        </td>
                                    </tr>
                                </table>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(26, 26, 26, 0.9); padding: 25px; border-radius: 12px; margin: 30px 0; border-left: 4px solid #667eea;">
                                    <tr>
                                        <td>
                                            <h4 style="color: #667eea; margin: 0 0 15px 0; font-size: 18px; font-weight: bold;">' . t('email.welcome.first_steps') . '</h4>
                                            <ol style="margin: 0; padding-left: 25px; font-size: 16px; line-height: 1.6; color: #a0aec0;">
                                                <li style="margin-bottom: 12px;">' . t('email.welcome.step1') . '</li>
                                                <li style="margin-bottom: 12px;">' . t('email.welcome.step2') . '</li>
                                                <li style="margin-bottom: 12px;">' . t('email.welcome.step3') . '</li>
                                                <li style="margin-bottom: 12px;">' . t('email.welcome.step4') . '</li>
                                            </ol>
                                        </td>
                                    </tr>
                                </table>
                                
                                <p style="font-size: 16px; text-align: center; color: #667eea; font-weight: bold; margin: 30px 0;">' . t('email.welcome.remember') . '</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top: 40px; padding-top: 30px; border-top: 1px solid rgba(255, 255, 255, 0.1);">
                                    <tr>
                                        <td align="center" style="padding: 20px 0;">
                                            <h3 style="margin: 0 0 20px 0; color: #667eea; font-size: 1.2rem;">' . t('email.welcome.stay_connected') . '</h3>
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">
                                                <a href="https://soundstudiopro.com" style="color: #667eea; text-decoration: none; margin: 0 10px;">' . t('email.welcome.website') . '</a> |
                                                <a href="mailto:support@soundstudiopro.com" style="color: #667eea; text-decoration: none; margin: 0 10px;">' . t('email.support_email') . '</a> |
                                                <a href="https://soundstudiopro.com/community_fixed.php" style="color: #667eea; text-decoration: none; margin: 0 10px;">' . t('nav.community') . '</a>
                                            </p>
                                            <p style="margin: 20px 0 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">' . t('email.thank_you_choosing') . '</p>
                                            <p style="margin: 0; color: #718096; font-size: 14px; line-height: 1.6;">' . t('email.welcome.creative_journey') . '</p>
                                            <p style="margin: 10px 0 0 0; color: #718096; font-size: 12px; line-height: 1.6;">&copy; ' . date('Y') . ' SoundStudioPro. ' . t('email.all_rights_reserved') . '</p>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
    </html>';
    
    // Build text version
    $text = t('email.welcome.title') . " - SoundStudioPro!\n\n";
    $text .= t('email.dear') . " $user_name,\n\n";
    $text .= t('email.welcome.creative_sanctuary') . "!\n\n";
    $text .= t('email.welcome.thrilled') . "\n\n";
    $text .= t('email.welcome.gift') . ": $credits " . t('email.credits') . " " . t('email.welcome.credits_waiting') . "\n\n";
    
    if ($password) {
        $text .= t('email.welcome.login_credentials') . ":\n";
        $text .= t('email.welcome.website') . ": https://soundstudiopro.com\n";
        $text .= t('email.email') . ": $user_email\n";
        $text .= t('login.password') . ": $password\n\n";
        $text .= t('email.welcome.save_credentials') . "\n\n";
    }
    
    $text .= t('email.welcome.what_awaits') . ":\n";
    $text .= "‱ " . t('email.welcome.ai_creation') . "\n";
    $text .= "‱ " . t('email.welcome.premium_library') . "\n";
    $text .= "‱ " . t('email.welcome.vibrant_community') . "\n";
    $text .= "‱ " . t('email.welcome.instant_access') . "\n\n";
    $text .= t('email.welcome.first_steps') . ":\n";
    $text .= "1. " . t('email.welcome.step1') . "\n";
    $text .= "2. " . t('email.welcome.step2') . "\n";
    $text .= "3. " . t('email.welcome.step3') . "\n";
    $text .= "4. " . t('email.welcome.step4') . "\n\n";
    $text .= t('email.go_to_dashboard') . ": https://soundstudiopro.com/dashboard.php\n\n";
    $text .= t('email.welcome.remember') . "\n\n";
    $text .= t('email.thank_you_choosing') . "\n";
    $text .= t('email.welcome.creative_journey') . "\n";
    $text .= "© " . date('Y') . " SoundStudioPro. " . t('email.all_rights_reserved');
    
    return [
        'html' => $html,
        'text' => $text,
        'subject' => t('email.welcome.title') . " - " . t('email.welcome.subtitle')
    ];
}

// Generate thank you email for Stéphane (French)
function generateStephanThankYouEmail($recipient_email = null) {
    $html = '
    <!DOCTYPE html>
    <html lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Merci StĂ©phane — +100 crĂ©dits offerts pour votre soutien!</title>
    </head>
    <body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0a0a0a;">
        <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #0a0a0a;">
            <tr>
                <td align="center" style="padding: 20px 0;">
                    <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="background-color: #1a1a1a; border-radius: 12px; overflow: hidden;">
                        <!-- Header -->
                        <tr>
                            <td bgcolor="#667eea" style="background-color: #667eea; padding: 40px 30px; text-align: center;">
                                <h1 style="margin: 0 0 10px 0; font-size: 2.5rem; font-weight: bold; color: #ffffff !important;">đŸŽ” SoundStudioPro</h1>
                                <h2 style="margin: 0 0 20px 0; font-size: 1.5rem; font-weight: 300; color: #ffffff !important;">đŸŽ” Merci StĂ©phane — +100 crĂ©dits offerts!</h2>
                            </td>
                        </tr>
                        <!-- Content -->
                        <tr>
                            <td style="background-color: #1a1a1a; padding: 40px 30px;">
                                <p style="margin: 0 0 15px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Bonjour Stéphane,</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Un immense merci pour votre achat de 500 crĂ©dits sur SoundStudioPro — et surtout pour votre magnifique tĂ©moignage.</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Vos mots nous ont vraiment touchés :</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(102, 126, 234, 0.1); padding: 25px; border-radius: 12px; margin: 25px 0; border-left: 4px solid #667eea;">
                                    <tr>
                                        <td>
                                            <p style="margin: 0; font-style: italic; font-size: 16px; line-height: 1.8; color: #ffffff; text-align: center;">
                                                « BRAVO Danny pour ce que tu fais, en développant ce site, tu nous permets d\'explorer de nouveaux horizons musicaux qui inspirent et qui bercent notre ùme. Merci. »
                                            </p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">C\'est exactement pour cela que SoundStudioPro existe : permettre à des créateurs comme vous d\'explorer de nouvelles fréquences, de nouveaux univers et des émotions musicales qui vibrent vraiment. Votre confiance nous motive à dépasser nos limites chaque jour.</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(34, 197, 94, 0.1); padding: 25px; border-radius: 12px; margin: 25px 0; border-left: 4px solid #22c55e;">
                                    <tr>
                                        <td>
                                            <h3 style="margin: 0 0 15px 0; color: #22c55e; font-size: 1.3rem; font-weight: bold;">🎁 Votre Cadeau de Remerciement</h3>
                                            <p style="margin: 0 0 15px 0; color: #ffffff; font-size: 18px; line-height: 1.6;">Pour vous remercier personnellement, nous avons ajouté <strong style="color: #22c55e;">100 crédits gratuits supplémentaires</strong> à votre compte.</p>
                                            <p style="margin: 0; color: #ffffff; font-size: 16px; line-height: 1.6;">Profitez-en pour créer, expérimenter et repousser les frontiÚres de votre imagination.</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: rgba(79, 172, 254, 0.1); padding: 25px; border-radius: 12px; margin: 25px 0; border-left: 4px solid #4facfe;">
                                    <tr>
                                        <td>
                                            <h3 style="margin: 0 0 15px 0; color: #4facfe; font-size: 1.3rem; font-weight: bold;">⭐ AccÚs Anticipé</h3>
                                            <p style="margin: 0; color: #ffffff; font-size: 16px; line-height: 1.6;">En plus, nous vous offrons un accÚs anticipé aux prochaines améliorations du modÚle, avant leur sortie publique. Vous recevrez un message dÚs que votre accÚs privilégié sera activé.</p>
                                        </td>
                                    </tr>
                                </table>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Si vous avez des idĂ©es, des demandes, ou mĂȘme des bogues Ă  nous signaler, n\'hĂ©sitez jamais Ă  m\'Ă©crire directement.</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Vous faites partie de ceux qui construisent SoundStudioPro avec nous.</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 16px; line-height: 1.6;">Merci encore StĂ©phane — continuons ensemble Ă  crĂ©er le futur de la musique.</p>
                                
                                <p style="margin: 0 0 20px 0; color: #a0aec0; font-size: 18px; line-height: 1.6; text-align: center;">đŸ”„đŸŽ¶</p>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 30px 0;">
                                    <tr>
                                        <td align="center">
                                            <a href="https://soundstudiopro.com/dashboard.php" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">Accéder à mon compte</a>
                                            <a href="https://soundstudiopro.com/dashboard.php?tab=credits" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #ffffff; padding: 14px 28px; text-decoration: none; border-radius: 8px; margin: 10px 5px; font-weight: 600; font-size: 16px;">Voir mes crédits</a>
                                        </td>
                                    </tr>
                                </table>
                                
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top: 40px; padding-top: 30px; border-top: 1px solid rgba(255, 255, 255, 0.1);">
                                    <tr>
                                        <td align="center" style="padding: 20px 0;">
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">Avec gratitude,</p>
                                            <p style="margin: 10px 0; color: #718096; font-size: 16px; line-height: 1.6; font-weight: bold;">Danny & l\'équipe SoundStudioPro</p>
                                            <p style="margin: 10px 0; color: #718096; font-size: 14px; line-height: 1.6;">SoundStudioPro.com</p>
                                            <p style="margin: 10px 0 0 0; color: #718096; font-size: 12px; line-height: 1.6;">&copy; ' . date('Y') . ' SoundStudioPro. Tous droits réservés.</p>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
    </html>';
    
    // Build text version
    $text = "đŸŽ” Merci StĂ©phane — +100 crĂ©dits offerts pour votre soutien!\n\n";
    $text .= "Bonjour Stéphane,\n\n";
    $text .= "Un immense merci pour votre achat de 500 crĂ©dits sur SoundStudioPro — et surtout pour votre magnifique tĂ©moignage.\n\n";
    $text .= "Vos mots nous ont vraiment touchés :\n\n";
    $text .= "« BRAVO Danny pour ce que tu fais, en développant ce site, tu nous permets d'explorer de nouveaux horizons musicaux qui inspirent et qui bercent notre ùme. Merci. »\n\n";
    $text .= "C'est exactement pour cela que SoundStudioPro existe : permettre à des créateurs comme vous d'explorer de nouvelles fréquences, de nouveaux univers et des émotions musicales qui vibrent vraiment. Votre confiance nous motive à dépasser nos limites chaque jour.\n\n";
    $text .= "🎁 Votre Cadeau de Remerciement\n\n";
    $text .= "Pour vous remercier personnellement, nous avons ajouté 100 crédits gratuits supplémentaires à votre compte.\n";
    $text .= "Profitez-en pour créer, expérimenter et repousser les frontiÚres de votre imagination.\n\n";
    $text .= "⭐ AccÚs Anticipé\n\n";
    $text .= "En plus, nous vous offrons un accÚs anticipé aux prochaines améliorations du modÚle, avant leur sortie publique. Vous recevrez un message dÚs que votre accÚs privilégié sera activé.\n\n";
    $text .= "Si vous avez des idĂ©es, des demandes, ou mĂȘme des bogues Ă  nous signaler, n'hĂ©sitez jamais Ă  m'Ă©crire directement.\n\n";
    $text .= "Vous faites partie de ceux qui construisent SoundStudioPro avec nous.\n\n";
    $text .= "Merci encore StĂ©phane — continuons ensemble Ă  crĂ©er le futur de la musique.\n\n";
    $text .= "đŸ”„đŸŽ¶\n\n";
    $text .= "Avec gratitude,\n";
    $text .= "Danny & l'équipe SoundStudioPro\n";
    $text .= "SoundStudioPro.com\n\n";
    $text .= "© " . date('Y') . " SoundStudioPro. Tous droits réservés.";
    
    return [
        'html' => $html,
        'text' => $text,
        'subject' => 'đŸŽ” Merci StĂ©phane — +100 crĂ©dits offerts pour votre soutien!'
    ];
}
?> 

CasperSecurity Mini