There is a simple form with the requirement of email. It is necessary that this data be sent from it to my email. How to implement it? I am sure it is not difficult, just need to know how. Thank!

<div class="w-form"> <form action="send.php" class="email-address w-clearfix" data-name="Email Form" id="mc_embed_signup" method="post" name="email-form"><input class="email-address w-input" data-name="Email" id="Email-Address" maxlength="256" name="email" placeholder="Enter your email address" required="required" type="email"><input class="button w-button" data-wait="Please wait..." type="submit" onclick="ga('send', 'event', 'Верхняяформа', 'submit')" value="Start playing today"></form> <div class="success-message-2 w-form-done"> <div>Thank you! Please check your email now.</div> </div> <div class="w-form-fail"> <div>Oops! Something went wrong while submitting the form</div> </div> </div> </div> 

UP

Created send.php, but does not work. A page opens with characters and everything on it. What's wrong?

 <?php if($_POST) { $to = "pianoforall.lessons@gmail.com"; //куда отправлять письмо $subject = "Новый"; //тема $message = 'Имейл: '.$_POST['email'].';'; $headers = "Content-type: text/html; charset=UTF-8 \r\n"; $headers .= "From: <news@new-pianoforall.com>\r\n"; $result = mail($to, $subject, $message, $headers); if ($result){ echo "Cообщение успешно отправленно. Пожалуйста, оставайтесь на связи"; } } ?> 
  • one
    Have you watched a thousand similar questions on this site before writing a question? - Alexey Shimansky
  • Yes. But I do not understand. I thought I would help here - Anton
  • one
    sending a letter to php mail - in my opinion completely ....... A message is not sent to an email in PHP - without ajax, a ready-made example is right in the question - Alexey Shimansky
  • Thanks for the tip! I am a log in this, so if the questions are stupid, then weeds. And from what address will it come? I caught the essence, but did not understand, where in this code is the line responsible for sending the email itself? <? php $ to = "some_mail@mail.ru"; $ subject = "Robot - Robot"; $ message = "Message, \ n message!"; $ headers = "From: keh192.bget.ru <abc@gmail.com> \ r \ nContent-type: text / plain; charset = windows-1251 \ r \ n"; mail ($ to, $ subject, $ message, $ headers); ?> - Anton
  • mail(.... - php.net/manual/ru/function.mail.php - Alexey Shimansky

1 answer 1

If the hosting has not disabled the mail () function, then try through it (example https://habrahabr.ru/sandbox/48759/ ) And if this function is still disabled, use smtp services

  • There is an e-mail section there, but what is the name of this function? Thank! - Anton