Skip to content

Instantly share code, notes, and snippets.

@rhamdeew
Last active August 29, 2015 14:02
Show Gist options
  • Save rhamdeew/c123df3227667d79eb55 to your computer and use it in GitHub Desktop.
Save rhamdeew/c123df3227667d79eb55 to your computer and use it in GitHub Desktop.
<?php
if(isset($_REQUEST['ajaxform']) && isset($_REQUEST['ajaxform']['m'])) {
$data = $_REQUEST['ajaxform'];
$message_type = $data['m'];
$types = array(
1 => array(
'subject' => 'Обратный звонок',
'to' => 'mail@mail.ru',
),
2 => array(
'subject' => 'Обратный звонок',
'to' => 'mail@mail.ru',
),
3 => array(
'subject' => 'Обратный звонок',
'to' => 'mail@mail.ru',
),
);
$labels = array(
'name' => 'Имя',
'phone' => 'Номер телефона',
'docs' => 'Пакет документов',
'email' => 'E-mail',
'sum' => 'Первоначальный взнос',
'complectation' => 'Комплектация',
'insuarance' => 'КАСКО',
'comment' => 'Комментарий',
);
if(isset($types[$message_type])) {
unset($data['m']);
$to = $types[$message_type]['to'];
$subject = $types[$message_type]['subject'];
$msg = '';
foreach ($data as $var => $value) {
if(isset($labels[$var]))
$msg.=$labels[$var]." : ".$value."\r\n";
else
$msg.=$var." : ".$value."\r\n";
}
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=utf-8";
$headers[] = "From: Solaris Promo <robot@mail.ru>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
if(mail($to, $subject, $msg, implode("\r\n", $headers)))
echo 1;
else echo 0;
}
else echo 0;
}
else echo 0;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment