61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
//required files
|
|
require 'phpmailer/src/Exception.php';
|
|
require 'phpmailer/src/PHPMailer.php';
|
|
require 'phpmailer/src/SMTP.php';
|
|
|
|
$settings = array(
|
|
'email_mail' => 'sklep@drmaterac.pl',
|
|
'email_host' => 'serwer2140447.home.pl',
|
|
'email_login' => 'sklep@drmaterac.pl',
|
|
'email_password' => 'Maliny48#',
|
|
'email_port' => 465,
|
|
);
|
|
|
|
if (isset($_POST['form_name'])) {
|
|
$data = $_POST;
|
|
|
|
$name = $data['form_name'];
|
|
$email = $data['form_email'];
|
|
$phone = $data['form_phone'];
|
|
$marketing = $data['form_marketing'] ? 'Tak' : 'Nie';
|
|
|
|
$mail = new PHPMailer();
|
|
|
|
//Server settings
|
|
$mail->isSMTP();
|
|
$mail->Host = $settings['email_host'];
|
|
$mail->SMTPAuth = true;
|
|
$mail->Username = $settings['email_login'];
|
|
$mail->Password = $settings['email_password'];
|
|
$mail->SMTPSecure = 'ssl';
|
|
$mail->Port = $settings['email_port'];
|
|
|
|
//Recipients
|
|
$mail->setFrom($settings['email_mail'], 'Dr Materac - Franczyza');
|
|
// $mail->addAddress('mci@drmaterac.pl');
|
|
$mail->addAddress('nontvong@gmail.com');
|
|
|
|
//Content
|
|
$mail->isHTML(true); //Set email format to HTML
|
|
$mail->Subject = $mailFrom; // email subject headings
|
|
$mail->Body = '<p>Imię: ' . $name . '</p>' .
|
|
'<p>E-mail: ' . $email . '</p>' .
|
|
'<p>Telefon: ' . $phone . '</p>' .
|
|
'<p>Marketing: ' . $marketing . '</p>';
|
|
|
|
// Success sent message alert
|
|
if ($mail->send()) {
|
|
$_SESSION["configurator_sended"] = true;
|
|
echo json_encode(array('status' => 'ok', 'message' => 'Wiadomość została wysłana pomyślnie'));
|
|
exit();
|
|
} else {
|
|
echo json_encode(array('status' => 'error', 'message' => 'Błąd podczas wysyłania wiadomości'));
|
|
exit();
|
|
}
|
|
}
|