'; $headers[] = 'Reply-To: ' . $replyTo; $headers[] = 'MIME-Version: 1.0'; $hasAttachment = isset($_FILES['anlage']) && $_FILES['anlage']['error'] !== UPLOAD_ERR_NO_FILE; if ($hasAttachment && $formType === 'bewerbung') { if ($_FILES['anlage']['error'] !== UPLOAD_ERR_OK || $_FILES['anlage']['size'] > $maxFileSize) { http_response_code(400); $statusTitle = 'Datei konnte nicht gesendet werden'; $statusText = 'Bitte laden Sie eine Datei bis maximal 10 MB hoch.'; include __DIR__ . '/send-status-template.php'; exit; } $originalName = basename($_FILES['anlage']['name']); $extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION)); if (!in_array($extension, $allowedExtensions, true)) { http_response_code(400); $statusTitle = 'Dateiformat nicht erlaubt'; $statusText = 'Erlaubt sind PDF, DOC, DOCX, JPG und PNG.'; include __DIR__ . '/send-status-template.php'; exit; } $boundary = 'omsorg_' . md5(uniqid((string)mt_rand(), true)); $headers[] = 'Content-Type: multipart/mixed; boundary="' . $boundary . '"'; $message = '--' . $boundary . "\r\n"; $message .= "Content-Type: text/plain; charset=UTF-8\r\n"; $message .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $message .= $bodyText . "\r\n\r\n"; $fileContent = chunk_split(base64_encode(file_get_contents($_FILES['anlage']['tmp_name']))); $safeFileName = preg_replace('/[^A-Za-z0-9._-]/', '_', $originalName); $finfo = new finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->file($_FILES['anlage']['tmp_name']) ?: 'application/octet-stream'; $message .= '--' . $boundary . "\r\n"; $message .= 'Content-Type: ' . $mimeType . '; name="' . $safeFileName . '"' . "\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= 'Content-Disposition: attachment; filename="' . $safeFileName . '"' . "\r\n\r\n"; $message .= $fileContent . "\r\n"; $message .= '--' . $boundary . '--'; } else { $headers[] = 'Content-Type: text/plain; charset=UTF-8'; $message = $bodyText; } $sent = mail($recipient, '=?UTF-8?B?' . base64_encode($subject) . '?=', $message, implode("\r\n", $headers)); if ($sent) { $statusTitle = 'Vielen Dank!'; $statusText = 'Ihre Nachricht wurde erfolgreich an OMSORG gesendet. Wir melden uns schnellstmöglich bei Ihnen.'; } else { http_response_code(500); $statusTitle = 'Versand nicht möglich'; $statusText = 'Die Nachricht konnte vom Server nicht versendet werden. Bitte kontaktieren Sie uns direkt per E-Mail: info@omsorg-pflegedienste.de'; } include __DIR__ . '/send-status-template.php';