Doubt to Call form in PHP to send by email

-1

I have a small problem when connecting the contact form to be sent by email, it is not sending by email and I could not understand the reason for this, below the code in html with the name contacto.html

 <form action="sendemail.php" id="main-contact-form" name="contact-form" method="post"  >
                <div class="row  wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
                  <div class="col-sm-12">
                    <div class="form-group">
                      <input type="text" name="Nome" class="form-control" placeholder="Nome" required="required">
                       <p class="help-block">Obrigatorio</p>
                    </div>
                  </div>
                  <div class="col-sm-12">
                    <div class="form-group">
                      <input type="email" name="Email" class="form-control" placeholder="Email" required="required">
                      <p class="help-block">Obrigatorio</p>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <input type="text" name="Instituição" class="form-control" placeholder="Instituição" >
                </div>
                <div class="form-group">
                  <textarea name="message" id="message" class="form-control" rows="4" placeholder="Escreve sua menssagem" required="required"></textarea>
                </div>                        
                <div class="form-group">
                  <button type="submit" class="btn-submit">Enviar</button>
                </div>
              </form>

Below is the php code named sendemail.php

<?php
$name       = @trim(stripslashes($_POST['Nome'])); 
$from       = @trim(stripslashes($_POST['Email'])); 
$subject    = @trim(stripslashes($_POST['Instituicao'])); 
$message    = @trim(stripslashes($_POST['message'])); 
$to   		= '[email protected]';//replace with your email




$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();

mail($to, $subject, $message, $headers);

?>

I'm pretty noob in php for hours, so I'm having this problem, the site is already on the server and I can not find the error.

    
asked by anonymous 24.06.2015 / 14:45

2 answers

0

Gabriel , correct the name of the field Instituição to Instituicao (no accents).

The mail() function of PHP is no longer recommended for sending e-mail because several reasons prevent e-mail from reaching the recipient, even a simple block of the server where the site is hosted or even the SPAM checks of the recipient.

Send using SMTP server and a class appropriate for this.

I recommend phpmailer , it's famous and very simple to implement. See a simple tutorial:

link

    
24.06.2015 / 16:35
0

As mentioned above, I also recommend using the PHPMailler email class. I use it already has a good time and never had problems with it, is simple to use and if your email is in the standard it will not enter as spam in the mailboxes of the mail servers (Gmail, Hotmail, etc.), because it has an entire authentication process.

Tip: Do not use variable or vector nomenclature with special characters, you will have trouble coding the file in the future.

link

    
24.06.2015 / 17:00