![]() 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/.cursor-server/data/User/History/4c77ac01/ |
<?php
// Email configuration for SoundStudioPro
// SMTP Configuration
define('SMTP_HOST', 'smtp.gmail.com');
define('SMTP_PORT', 587);
define('SMTP_USERNAME', 'noreply@soundstudiopro.com'); // Update with actual email
define('SMTP_PASSWORD', 'your_app_password_here'); // Update with actual password
define('SMTP_FROM_EMAIL', 'noreply@soundstudiopro.com');
define('SMTP_FROM_NAME', 'SoundStudioPro');
// Email sending function using PHPMailer
function sendEmail($to_email, $to_name, $subject, $html_body, $text_body = null) {
// Check if PHPMailer is available
if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) {
// Fallback to basic mail() function
$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";
return mail($to_email, $subject, $html_body, $headers);
}
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
$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");
return true;
} catch (Exception $e) {
error_log("Email sending failed: " . $mail->ErrorInfo);
return false;
}
}
// Generate order confirmation email
function generateOrderConfirmationEmail($user_name, $order_details, $billing_address) {
$order_number = 'SSP-' . date('Ymd') . '-' . strtoupper(substr(md5(uniqid()), 0, 8));
$order_date = date('F j, Y \a\t g:i A');
$total_amount = number_format($order_details['total_amount'] / 100, 2);
// Build order items HTML
$items_html = '';
foreach ($order_details['cart_summary'] as $item) {
if ($item['type'] === 'credit') {
$items_html .= '
<tr>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0;">' . htmlspecialchars($item['name']) . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: center;">' . $item['quantity'] . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: right;">$' . number_format($item['amount'] / 100, 2) . '</td>
</tr>';
} else {
$items_html .= '
<tr>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0;">' . htmlspecialchars($item['title']) . ' by ' . htmlspecialchars($item['artist']) . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: center;">' . $item['quantity'] . '</td>
<td style="padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: right;">$' . number_format($item['amount'] / 100, 2) . '</td>
</tr>';
}
}
$html = '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Confirmation - SoundStudioPro</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
.header { background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 30px; text-align: center; border-radius: 10px 10px 0 0; }
.content { background: #f8f9fa; padding: 30px; border-radius: 0 0 10px 10px; }
.order-number { background: #667eea; color: white; padding: 10px 20px; border-radius: 5px; display: inline-block; margin: 10px 0; }
.order-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.order-table th { background: #667eea; color: white; padding: 12px; text-align: left; }
.order-table td { padding: 12px; border-bottom: 1px solid #e2e8f0; }
.total-row { font-weight: bold; background: #f1f5f9; }
.billing-info { background: white; padding: 20px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #667eea; }
.footer { text-align: center; margin-top: 30px; color: #666; font-size: 14px; }
.btn { display: inline-block; background: #667eea; color: white; padding: 12px 24px; text-decoration: none; border-radius: 5px; margin: 10px 5px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🎵 SoundStudioPro</h1>
<h2>Order Confirmation</h2>
<div class="order-number">Order #' . $order_number . '</div>
<p>Thank you for your purchase!</p>
</div>
<div class="content">
<p>Dear ' . htmlspecialchars($user_name) . ',</p>
<p>Thank you for your order! We\'re excited to confirm that your payment has been processed successfully. Here are the details of your purchase:</p>
<h3>📋 Order Details</h3>
<table class="order-table">
<thead>
<tr>
<th>Item</th>
<th style="text-align: center;">Qty</th>
<th style="text-align: right;">Price</th>
</tr>
</thead>
<tbody>
' . $items_html . '
<tr class="total-row">
<td colspan="2" style="text-align: right; font-weight: bold;">Total:</td>
<td style="text-align: right; font-weight: bold;">$' . $total_amount . '</td>
</tr>
</tbody>
</table>
<div class="billing-info">
<h4>📍 Billing Information</h4>
<p><strong>Name:</strong> ' . htmlspecialchars($billing_address['billing_first_name'] . ' ' . $billing_address['billing_last_name']) . '</p>
<p><strong>Email:</strong> ' . htmlspecialchars($billing_address['billing_email']) . '</p>
<p><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>
</div>
<h3>🎁 What\'s Next?</h3>';
// Add specific next steps based on what was purchased
$has_credits = false;
$has_tracks = false;
foreach ($order_details['cart_summary'] as $item) {
if ($item['type'] === 'credit') $has_credits = true;
if ($item['type'] === 'track') $has_tracks = true;
}
if ($has_credits) {
$html .= '
<p><strong>🎯 Credits Added:</strong> Your credits have been automatically added to your account and are ready to use for creating music!</p>
<p>You can start creating amazing music right away by visiting your dashboard.</p>';
}
if ($has_tracks) {
$html .= '
<p><strong>🎵 Tracks Purchased:</strong> Your purchased tracks are now available in your music library for download.</p>
<p>You can access them anytime from your account dashboard.</p>';
}
$html .= '
<div style="text-align: center; margin: 30px 0;">
<a href="https://soundstudiopro.com/dashboard.php" class="btn">Go to Dashboard</a>
<a href="https://soundstudiopro.com/credits.php" class="btn">View Credits</a>
</div>
<h3>💡 Need Help?</h3>
<p>If you have any questions about your order or need assistance, please don\'t hesitate to contact our support team:</p>
<ul>
<li>📧 Email: support@soundstudiopro.com</li>
<li>🌐 Website: <a href="https://soundstudiopro.com/support">soundstudiopro.com/support</a></li>
</ul>
<p><strong>Order Date:</strong> ' . $order_date . '</p>
<p><strong>Payment Method:</strong> Credit Card (Processed by Stripe)</p>
<div class="footer">
<p>Thank you for choosing SoundStudioPro!</p>
<p>© ' . date('Y') . ' SoundStudioPro. All rights reserved.</p>
<p>This email was sent to ' . htmlspecialchars($billing_address['billing_email']) . '</p>
</div>
</div>
</div>
</body>
</html>';
return [
'html' => $html,
'text' => "Order Confirmation - SoundStudioPro\n\nDear $user_name,\n\nThank you for your order! Your payment has been processed successfully.\n\nOrder #$order_number\nOrder Date: $order_date\nTotal: \$$total_amount\n\nYour credits and tracks are now available in your account.\n\nVisit: https://soundstudiopro.com/dashboard.php\n\nThank you for choosing SoundStudioPro!",
'subject' => "Order Confirmation - SoundStudioPro (Order #$order_number)"
];
}
?>