Application ERROR after mail sending

Hello guys, i’am trying to use mail from php but something is wrong, it works but then it is displayed

Application error

An error occurred in the website and your page could not be displayed. If you are the website owner, check your logs for details.

So i can’t redirect the page.

somethings about the code

– form





Nome
      <div class="input-field">
        <input name="email" type="email" class="validate">
        <label for="email">Email</label>
      </div>
      <div class="input-field">
        <textarea autocomplete="off" required id="descricao" name="descricao" class="materialize-textarea text-white"></textarea>
        <label for="descricao">Descricão</label>
      </div>
      <div class="input-field">
        <input class="btn carousel-background waves-effect waves-light"  type="submit" value="Enviar">
      </div>
    </div>
  </div>

</form>

–class method
public function send($tipo){
try{
mail(‘mensageirosdeemanuel.go@gmail.com’, $tipo ,$this->getDescricao());
header(“Location :”.BASE_URL.“Home”);
}catch(Exception $e){
throw $e;
}

}

– controller method
public function send(){
if(isset($_POST[‘descricao’]) && !empty(’$_descricao’)){
$mensagem = new Mensagem();
$mensagem->setEmail(addslashes((isset($_POST[‘email’])?$_POST[‘email’]:‘Sem email’)));
$mensagem->setNome(addslashes((isset($_POST[‘nome’])?$_POST[‘nome’]:‘Sem nome’)));
$mensagem->setDescricao(addslashes($_POST[‘descricao’])."\nNome: “. $mensagem->getNome().”\nEmail: ".$mensagem->getEmail());

        $mensagem->send("Pedido de Oração");
          
        header("Location :".BASE_URL."Home");
        exit;  
        }
        header("Location :".BASE_URL."Home");
          
  }

Is error reporting on?

Yes, error reporting is on

Add this to the top of your PHP code

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

The Application error continues, you can see it


The form that you can test this is in footer, but what is strange is that the email is sent

It’s a PHP issue, find it :slight_smile:

1 Like