• PHP Help
  • Can anyone help me find the problem in my php code form?

My form always worked and now it gives me an error. I never changed the code. I´m using this for years. Its very strange.

These are the 2 files, if someone could help I would really appreciate

Main Code

https://pastebin.com/d7scjppa

Send form

https://pastebin.com/221VQShn

When I click the send button gives me this error on the top of the page in the end of the url ?erro=email. I´ve tried to edit the form, since I don´t work with php for long time and its not working still. 📷 Thank you in advance.

    NogDog On the form just doesn´t let me send it to my e-mail like it used to do. And on the url in the end comes something like this www.url.com/form..php?erro=email

    well for example the same happens on my e-mail and all was working fine, the error that happens on e-mail is:We encountered an error while sending your e-mail

    would be this a server issue?

    rocknrolla83 would be this a server issue?

    Probably:

    	 $sent = mail($to, $subject, $message, $headers) ; 
    	 if($sent) 
    		header("Location: ".$_SERVER["HTTP_REFERER"]."?sucesso=email");
    	 else 
    		header("Location: ".$_SERVER["HTTP_REFERER"]."?erro=email");
    

    IIRC, many mail servers require that the "From" header be a valid email account on that site; so if, for example, your email address there is "rocknrolla83@example.com", you could see if changing the headers to something like this helps:

     $headers = 'From: rocknrolla83@example.com' . "\r\n" .
          'Reply-To: . $_POST['email'] . "\r\n" .
          'X-Mailer: PHP/' . phpversion();
      

    (From https://www.php.net/manual/en/function.mail.php#example-3009)

      Write a Reply...