portfolio/backend/templates/emailTemplate.php

35 lines
No EOL
2 KiB
PHP

<?php
function renderEmailTemplate(string $name, string $email, string $text, string $paramsMessage): string {
// Pre-fill reply parameters using rawurlencode (%20 for spaces)
$replySubject = rawurlencode("Re: Portfolio Contact from $name");
$replyBody = rawurlencode("\n\n---\nOriginal message from $name ($email):\n" . $paramsMessage);
$mailtoLink = "mailto:$email?subject=$replySubject&body=$replyBody";
// Cleaned message body to avoid double breaks
$formattedText = nl2br(trim($text));
return "
<div style='width: 100%; height: 100%; background-color: #fff; font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;'>
<div style='background-color: #020617; color: #f8fafc; padding: 28px; max-width: 800px; margin: 0 auto; border: 1px solid #1e293b; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);'>
<div style='margin-bottom: 20px;'>
<span style='font-family: monospace; color: #3b82f6; font-size: 12px;'>// Portfolio Contact Message</span>
<h2 style='margin: 6px 0 0 0; color: #ffffff; font-size: 20px;'>New message from $name</h2>
</div>
<div style='background-color: #0f172a; border: 1px solid #1e293b; padding: 18px; border-radius: 8px; margin-bottom: 24px;'>
<div style='font-family: monospace; font-size: 12px; color: #64748b; margin-bottom: 12px;'>
<span style='color: #3b82f6;'>From:</span> $name ($email)
</div>
<div style='font-size: 14px; line-height: 1.6; color: #cbd5e1;'>{$formattedText}</div>
</div>
<div style='border-top: 1px solid #1e293b; padding-top: 20px; text-align: center;'>
<a href='$mailtoLink' style='display: inline-block; padding: 12px 24px; background-color: #2563eb; color: #ffffff; font-weight: 500; text-decoration: none; border-radius: 8px; font-size: 13px; font-family: monospace;'>
➜ Quick Reply
</a>
</div>
</div>
</div>
";
}