diff --git a/konfigurator-mail.php b/konfigurator-mail.php index 17edf03..8c99750 100644 --- a/konfigurator-mail.php +++ b/konfigurator-mail.php @@ -3,7 +3,7 @@ session_start(); require_once 'phpmailer/class.phpmailer.php'; require_once 'phpmailer/class.smtp.php'; -function send_email( $email, $reply, $subject, $text ) +function send_email( $email, $reply, $subject, $text, $attachment = null ) { $mail = new PHPMailer; $mail -> IsSMTP(); @@ -27,40 +27,60 @@ function send_email( $email, $reply, $subject, $text ) $mail -> isHTML( true ); $mail -> Subject = $subject; $mail -> Body = $text; + + if ($attachment && isset($attachment['tmp_name']) && file_exists($attachment['tmp_name'])) { + $mail->addAttachment($attachment['tmp_name'], $attachment['name']); + } + return $mail -> send(); } +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $configData = json_decode($_POST['configData'], true); -$data = json_decode(file_get_contents('php://input'), true); -$configData = $data['configData']; + $file = isset($_FILES['attachment']) ? $_FILES['attachment'] : null; -$to = 'kontakt@ostal.pl'; -$subject = 'ostal.pl - Konfigurator'; -$message = '
' . $configData['step_1'] . '
'; + $to = 'kontakt@ostal.pl'; + $subject = 'ostal.pl - Konfigurator'; + $message = '' . $configData['step_1'] . '
'; -$message .= 'Wymiary
'; -$message .= 'Wymiary
'; + $message .= '' . $configData['step_3'] . '
'; + $message .= '' . $configData['step_3'] . '
'; -$message .= 'Dane kontaktowe
'; -$message .= '' . $configData['step_3_extra'] . '
'; + } -if ( send_email( $to, $configData['step_4']['email'], $subject, $message, $headers ) ) -{ - // send_email( 'biuro@project-pro.pl', $configData['step_4']['email'], $subject, $message, $headers ); - $_SESSION["configurator_sended"] = true; - echo json_encode(array('status' => 'ok', 'message' => 'Wiadmość wysłana')); + $message .= 'Dane kontaktowe
'; + $message .= 'Klient prywatny , klient biznesowy
+ +{{acfData.acf.step_4.phone}}
+{{acfData.acf.step_4.attachment}}
+ +