Jump to content

Email script sending blank email


noerodaba

Recommended Posts

<section id="contact-page" class="container">
        <div class="row-fluid">


            <div class="span8">
                <h4>Contacto</h4>
                <div class="status alert alert-success" style="display: none"></div>


                <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
                  <div class="row-fluid">
                    <div class="span5">
                        <label>Nombre</label>
                        <input type="text" class="input-block-level" required placeholder="...">
                        <label>Asunto</label>
                        <input type="text" class="input-block-level" required placeholder="...">
                        <label>E-mail </label>
                        <input type="text" class="input-block-level" required placeholder="...">
                    </div>
                    <div class="span7">
                        <label>Mensaje</label>
                        <textarea name="message" id="message" required class="input-block-level" rows="8"></textarea>
                    </div>


                </div>
                <button type="submit" class="btn btn-primary btn-large pull-right">Enviar mensaje</button>
                <p> </p>


            </form>
        </div>

This above is the html form code I have .

 php email script I am using is below

<?php
	header('Content-type: application/json');
	$status = array(
		'type'=>'success',
		'message'=>'Su e-mail ha sido enviado. Nos pondremos en contacto con usted lo antes posible'
	);

    $name = @trim(stripslashes($_POST['Nombre'])); 
    $email = @trim(stripslashes($_POST['E-mail'])); 
    $subject = @trim(stripslashes($_POST['asunto'])); 
    $message = @trim(stripslashes($_POST['Mensaje'])); 

    $email_from = $email;
    $email_to = 'tallerdelinstrumento@gmail.com';

    $body = 'Nombre: ' . $name . "\n\n" . 'E-mail: ' . $email . "\n\n" . 'Asunto: ' . $subject . "\n\n" . 'Mensaje: ' . $message;

    $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

    echo json_encode($status);
    die;
	
	?>

Thats the code I am using for form . The javascript code is the following

jQuery(function($) {

	//Ajax contact
	var form = $('.contact-form');
		form.submit(function () {
			$this = $(this);
			$.post($(this).attr('action'),$(this).serialize(), function(data) {
			$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
		},'json');
		return false;
	});

	//Goto Top
	$('.gototop').click(function(event) {
		 event.preventDefault();
		 $('html, body').animate({
			 scrollTop: $("body").offset().top
		 }, 500);
	});	
	//End goto top		

});

I recieved the e-mail, but the content is blank.  I don´t find the mistake. Please help, I´m new student in this topic. Thanks you!!

Link to comment
Share on other sites

I changed the name, but still got a blank mail

 <section id="contact-page" class="container">
        <div class="row-fluid">

            <div class="span8">
                <h4>Contacto</h4>
                <div class="status alert alert-success" style="display: none"></div>

                <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
                  <div class="row-fluid">
                    <div class="span5">
                        <label>Nombre</label>
                        <input type="text" name="name" class="input-block-level" required placeholder="...">
                        <label>E-mail</label>
                        <input type="text" name="email" class="input-block-level" required placeholder="...">
                        <label>Asunto </label>
                        <input type="text" name="subject" class="input-block-level" required placeholder="...">
                    </div>
                    <div class="span7">
                        <label>Mensaje</label>
                        <textarea name="message" id="message" required class="input-block-level" rows="8"></textarea>
                    </div>

                </div>
                <button type="submit" class="btn btn-primary btn-large pull-right">Enviar mensaje</button>
                <p> </p>

            </form>
        </div>
<?php
	header('Content-type: application/json');
	$status = array(
		'type'=>'success',
		'message'=>'Su e-mail ha sido enviado. Nos pondremos en contacto con usted lo antes posible'
	);

    $name = @trim(stripslashes($_POST['name'])); 
    $email = @trim(stripslashes($_POST['email'])); 
    $subject = @trim(stripslashes($_POST['subject'])); 
    $message = @trim(stripslashes($_POST['message'])); 

    $email_from = $email;
    $email_to = 'tallerdelinstrumento@gmail.com';

    $body = 'name: ' . $name . "\n\n" . 'email: ' . $email . "\n\n" . 'subject: ' . $subject . "\n\n" . 'message: ' . $message;

    $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

    echo json_encode($status);
    die;
	
	?>

I don´t know where is the mistake.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.