Formulario PHP que no envía correo electrónico o muestra algún signo de problemas

I cannot for the life of me get my PHP form to send an email. I have tried a million different way to make this work, followed 10 tutorials so far and still no luck.

Here is my form and php code (these are all in the index.php file):

<?php

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

            if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message']) ) {

                $sender_name = $_POST['name'];
                $email_address = $_POST['email'];
                $subject = $_POST['subject'];
                $message = $_POST['message'];

                if ( !empty($sender_name) && !empty($email_address) && !empty($subject) && !empty($$message) ) {

                    $to = 'myemail@myemail.com';
                    $mailSubject = 'Contact Form Subject:' .$subject;
                    $mailSubject .= ' Sent from:' .$sender_name;
                    $body = $message;
                    $headers = 'From: ' .$email_address;

                    mail($to, $mailSubject, $body, $headers);

                }


            }

        ?>    





<form method="post" action="index.php">
                                    <div class="5grid">
                                        <div class="row">
                                            <div class="6u">
                                                <input type="text" name="name" id="name" placeholder="Name" />
                                            </div>
                                            <div class="6u">
                                                <input type="text" name="email" id="email" placeholder="Email" />
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="12u">
                                                <input type="text" name="subject" id="subject" placeholder="Subject" />
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="12u">
                                                <textarea name="message" id="message" placeholder="Message"></textarea>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="12u">
                                                <input type="submit" value="Send" class="button form-button-submit"/>
                                                <a href="#" class="button button-alt form-button-reset">Clear Form</a>
                                            </div>
                                        </div>
                                    </div>
                                </form>

I do not recieve ANY errors at all, it just doesnt send the email. Am I specifially doing something wrong here? Thanks in advance.

preguntado el 24 de abril de 13 a las 23:04

Where is your form hosted? -

I am currently using this on local host with MAMP for testing, which I have had no issues using in the past. -

1 Respuestas

You have a double $ when testing if the message is empty. This simple fix solved the problem for me.

if ( !empty($sender_name) && !empty($email_address) && !empty($subject) && !empty($$message) ) {

Respondido 24 Abr '13, 23:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.