Hello, the form does not work on VPS, but if you copy the site entirely to the hosting, then everything works great! Thank you in advance!

HTML form itself

<div class="subscription"> <div class="close_modal cursor"></div> <form class="fofms" action=""><noindex> <h5>Подписка&nbsp;на&nbsp;рассылку!</h5> <h6>Подписавшись, вы будете получили наши новости на почту!</h6> <input class="input" name="txtname" type="text" placeholder="* Имя" required><br> <input class="input" name="txtphone" type="text" id="txtphone" placeholder="* Телефон" required><br> <input class="input" name="txtemail" type="mail" placeholder="* Электронная почта" required><br><br> <label style="border-bottom: 1px Dotted transparent;"> <div style="position:absolute;top: 64px;left: 257px;"><img src="../images/konvert1.png"></div> <div class="checkboxtop2"> <input class="checkbox0" type="checkbox"><div class="checkboxtop2_txt">Я не робот</div> </div> </label> <input type="hidden" name="valTrFals" class="valTrFals" value="valTrFals_disabled"> <div class="mr_t10"> <p style="position: absolute;margin: -45px 0 0 0px;">Нажмите я не робот!</p> <input type="submit" class="button button-rounded button-flat-primary advice_botton" style="height: 30px;" value="Подписаться на рассылку" disabled="disabled" name="btnsend"> </div> </noindex></form> </div> <div class="subscription_ok"> <div class="close_modal cursor"></div> <div class="windows"> <div class="insText"><noindex> <p><strong>Ваша подписка оформлена.</strong>Спасибо за подписку! Теперь вы первыми узнаете об акциях с новинками от МФО и Банках!</p> <p>Для отмены подписки, напишите нам на почту, support@cachebank.ru с темой "отмена подписки!"</p> <p><div class="button button-rounded button-flat-primary advice_botton"><div class="close_modal cursor"><div class="ok2">Все понятно</div></div></div></p> </noindex></div> </div> </div> 

PHP form handler

 <?php //проверяем значения полученые при проверке скриптом формы if (trim($_POST['valTrFals'])!='valTrFals_true') { } else { $txtname = trim($_POST['txtname']); $txtphone = trim($_POST['txtphone']); $txtemail = trim($_POST['txtemail']); // от кого $fromMail = 'robot@cachebank.ru'; $fromName = 'КЭШБАНК Подписка!'; // Сюда введите Ваш email $emailTo = 'kim.hahin@gmail.com'; $subject = 'Подписка на рассылку!'; $subject = '=?utf-8?b?'. base64_encode($subject) .'?='; $headers = "Content-type: text/plain; charset=\"utf-8\"\r\n"; $headers = "From: ". $fromName ." <". $fromMail ."> \r\n"; // тело письма $body = "Письмо получено с сайта www.cachebank.ru\nИмя: $txtname \nТелефон: $txtphone \nE-mail: $txtemail"; $mail = mail($emailTo, $subject, $body, $headers, '-f'. $fromMail ); echo 'ok'; } ?> 

JS Forms

 jQuery(document).ready(function($){ //в этой функции отслеживается изменение чекбокса "я не робот" $(document).on('change', '.fofms input:checkbox', function() { if($(this).is(':checked')){ $(".fofms input[type=submit]").removeAttr('disabled'); $('.fofms input[type=hidden].valTrFals').val('valTrFals_true'); } else { $(".fofms input[type=submit]").attr('disabled','disabled'); $('.fofms input[type=hidden].valTrFals').val('valTrFals_disabled'); } }); //закрытие модального окна $('.close_modal, .overlay').click(function (){ $('.subscription, .subscription_ok, .overlay').css({'opacity':'0', 'visibility':'hidden'}); $('.subscription > .fofms textarea').val(''); //сброс всех полей формы обраной связи $(':input','.fofms').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected'); $(".fofms input[type=submit]").attr('disabled','disabled'); }); //показ модального окна $('.open_modal_subscription').click(function (e){ e.preventDefault(); $('.subscription, .overlay').css({'opacity':'1', 'visibility':'visible'}); }); //аякс форма обратной связи //проверяет какой ответ был получен //и в зависимости от ответа //выводит информацию о статусе //отправки письма $(".fofms").submit(function() { var str = $(this).serialize(); $.ajax({ type: "POST", url: "../function/subscription.php", data: str, success: function(msg) { if(msg == 'ok') { $('.subscription_ok, .overlay').css('opacity','1'); $('.subscription_ok, .overlay').css('visibility','visible'); $('.subscription').css({'opacity':'0','visibility':'hidden'}); } else { $('.subscription_ok .windows').html('<h5>Ошибка</h5><p>Сообщение не отправлено, убедитесь в правильности заполнение полей</p>'); $('.subscription_ok, .overlay').css('opacity','1'); $('.subscription_ok, .overlay').css('visiFbility','visible'); $('.subscription').css({'opacity':'0','visibility':'hidden'}); } } }); return false; }); }); 
  • Maybe the ability to send letters to the mail () function is not included on the VPS? - Ilya Yaremchuk
  • Honestly, I don’t know much about vps servers and the console, I’ll be glad if you tell me how to do this, check whether it is enabled or not? - Limbo

1 answer 1

Check if the php mail() function works on the server, if unix / linux:

 echo "Testing" | mail -s "Test" test@example.com 

Check in php.ini whether the mail function is not prohibited:

 disable_functions 

You can also check out:

 if ( function_exists( 'mail' ) ) { echo 'mail() is available'; } else { echo 'mail() has been disabled'; } 
  • one
    in php.ini (disable_functions =) - Limbo
  • and through your mail () is available code - Limbo
  • @limbo after php.ini changes don't forget to restart the server - Ilya Yaremchuk
  • I've found something in php.ini, maybe there is a problem? if I have port 25 open [mail function] SMTP = localhost smtp_port = 25 sendmail_path = / usr / lib / sendmail -t -i -f - Limbo
  • Try sendmail_path = / usr / sbin / sendmail -t -i -F "Full Name" -f'emailaddress@example.com ' - Ilya Yaremchuk