<?php
file_put_contents('post.log',print_r($_POST,1));
$project_name = '
site.ru';
$admin_email = 'mail@mail.ru';
$form_subject = trim($_POST["form_subject"]);
$my_mail = 'info@modhost.pro';
$c = "";
$message = "";
foreach ( $_POST as $key => $value ) {
if ( $value != "" && $key != "form_subject" ) {
$print_key = str_replace('_',' ',$key);
if (substr($value,0,5) == 'https') {
$links = explode(',',$value);
$value = '';
foreach ($links as $id => $link) {
$value .= "<a href='".$link."' target='_blank'>".$link."</a>
";
}
}
$message .= "
" . (($c = !$c) ? '<tr>' : '<tr style="background-color: #f8f8f8;">') . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$print_key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
$message = "<table style='width: 50%;'>$message</table>";
// Подключаем MODX API
define('MODX_API_MODE', true);
require dirname(
DIR) . '/index.php';
$modx->log(1, 'OK');
// Отправляем письмо
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->address('to', $admin_email);
$modx->mail->set(modMail::MAIL_FROM, $my_mail);
$modx->mail->set(modMail::MAIL_FROM_NAME, $project_name);
$modx->mail->set(modMail::MAIL_SUBJECT, $form_subject);
$modx->mail->set(modMail::MAIL_BODY, $message);
$modx->mail->setHTML(true);
if ($modx->mail->send()) {
echo '200';
} else {
echo '500';
}
$modx->mail->reset();