65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'phpmailer/class.phpmailer.php';
|
|
require_once 'phpmailer/class.smtp.php';
|
|
|
|
function send_email( $email, $reply, $subject, $text )
|
|
{
|
|
$mail = new PHPMailer;
|
|
$mail -> IsSMTP();
|
|
$mail -> SMTPAuth = true;
|
|
$mail -> Host = 'mail.ostal.pl';
|
|
$mail -> Port = 25;
|
|
$mail -> Username = 'konfigurator@ostal.pl';
|
|
$mail -> Password = 'x6rpeUG5tW';
|
|
$mail -> CharSet = "UTF-8";
|
|
$mail -> SMTPOptions = array(
|
|
'ssl' => array(
|
|
'verify_peer' => false,
|
|
'verify_peer_name' => false,
|
|
'allow_self_signed' => true
|
|
)
|
|
);
|
|
$mail -> From = 'konfigurator@ostal.pl';
|
|
$mail -> FromName = 'Ostal';
|
|
$mail -> addAddress( $email, $email );
|
|
$mail -> addReplyTo( $reply, $reply );
|
|
$mail -> isHTML( true );
|
|
$mail -> Subject = $subject;
|
|
$mail -> Body = $text;
|
|
return $mail -> send();
|
|
}
|
|
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$configData = $data['configData'];
|
|
|
|
$to = 'kontakt@ostal.pl';
|
|
$subject = 'ostal.pl - Konfigurator';
|
|
$message = '<p>' . $configData['step_1'] . '</p>';
|
|
|
|
$message .= '<p>Wymiary</p>';
|
|
$message .= '<ul>';
|
|
$message .= '<li>Długość: ' . $configData['step_2']['height'] . 'mm </li>';
|
|
$message .= '<li>Szerokość: ' . $configData['step_2']['length'] . 'mm </li>';
|
|
$message .= '<li>Wysokość: ' . $configData['step_2']['width'] . 'mm </li>';
|
|
$message .= '</ul>';
|
|
|
|
$message .= '<p>' . $configData['step_3'] . '</p>';
|
|
|
|
$message .= '<p>Dane kontaktowe</p>';
|
|
$message .= '<ul>';
|
|
$message .= '<li>Imię: ' . $configData['step_4']['name'] . '</li>';
|
|
$message .= '<li>E-mail: ' . $configData['step_4']['email'] . '</li>';
|
|
$message .= '<li>Telefon: ' . $configData['step_4']['phone'] . '</li>';
|
|
$message .= '</ul>';
|
|
|
|
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'));
|
|
exit();
|
|
} else {
|
|
echo json_encode(array('status' => 'error', 'message' => 'Wystąpił błąd'));
|
|
exit();
|
|
} |