Jump to content
Fórum Script Brasil
  • 0

felipeitalves
 Share

Question

Olá galera, bom dia.

Estou com um problema no meu sendemail.php, a função mail esta funcionando sem problemas só que minhas variáveis estão retornando vazias, no e-mail chega todo em branco e sem assunto. Vou colocar meu código abaixo:

INDEX.PHP

                           

<form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
                                <div class="form-group">
                                    <input type="text" name="nome" class="form-control" placeholder="Nome" required>
                                </div>
                                <div class="form-group">
                                    <input type="email" name="email" class="form-control" placeholder="E-mail" required>
                                </div>
                                <div class="form-group">
                                    <input type="text" name="assunto" class="form-control" placeholder="Assunto" required>
                                </div>
                                <div class="form-group">
                                    <textarea name="mensagem" class="form-control" rows="8" placeholder="Mensagem" required></textarea>
                                </div>
                                <button type="submit" class="btn btn-primary">Send Message</button>
                            </form>

 

SENDEMAIL.PHP

<?PHP

$name       = @trim(stripslashes($_POST['nome']));
$from       = @trim(stripslashes($_POST['email']));
$subject    = @trim(stripslashes($_POST['assunto']));
$message    = @trim(stripslashes($_POST['mensagem']));
$to           = '[email protected]';

$body = 'Nome: ' . $name . "\n\n" . 'E-mail: ' . $from . "\n\n" . 'Telefone: ' . $subject . "\n\n" . 'Mensagem: ' . $message;

$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: [email protected]\r\n";
$headers .= "Return-Path: [email protected]\r\n";

@mail($to, $subject, $body, $headers, "-r" . "[email protected]");

die;

Código Ajax:

 

// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Enviando e-mail</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Obrigado pelo seu contato</p>').delay(3000).fadeOut();
});


});

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...