1

From code below you can see I am trying to create contact which is send to XXX@gmail.com. After filled form and click on SEND EMAIL I get message "Email sent!". That is OK.
Why I do not receive contact form to my email xxx@gmail.com?

 <?php
    $action=$_REQUEST['action'];
    if ($action=="")    /* display the contact form */
        {
        ?>
        <form  action="" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="action" value="submit">
        Your name:<br>
        <input name="name" type="text" value="" size="30"/><br>
        Your email:<br>
        <input name="email" type="text" value="" size="30"/><br>
        Your message:<br>
        <textarea name="message" rows="7" cols="30"></textarea><br>
        <input type="submit" value="Send email"/>
        </form>
        <?php
        } 
    else                /* send the submitted data */
        {
        $name=$_REQUEST['name'];
        $email=$_REQUEST['email'];
        $message=$_REQUEST['message'];
        if (($name=="")||($email=="")||($message==""))
            {
            echo "All fields are required, please fill <a href=\"\">the form</a> again.";
            }
        else{        
            $from="From: $name<$email>\r\nReturn-path: $email";
            $subject="Message sent using your contact form";
            mail("XXX@gmail.com", $subject, $message, $from);
            echo "Email sent!";
            }
        }  
    ?>
Luxqs
  • 53
  • 10
  • 1
    Clue: Take a long look at `$from` ;-) – Funk Forty Niner Jan 26 '15 at 14:06
  • 1
    Add error reporting to the top of your file(s) right after your opening ` – Funk Forty Niner Jan 26 '15 at 14:14
  • I see where is error but I dnot know how to fix it (thanks to your line of code) – Luxqs Jan 26 '15 at 14:19
  • 2
    You're welcome. The answer is inside the link as a duplicate. If you haven't figured it out in 15 mins. I'll give you the answer. The reason is simple; I want you to learn and not spoonfeed you. That's why the question was closed; the variable i undefined. Go over that link and compare it with yours as to why it's doing that, using Gmail's server as the `From:`. – Funk Forty Niner Jan 26 '15 at 14:21
  • 1
    ..and the manual of course http://php.net/manual/en/function.mail.php which I'm sure is inside the duplicate link. – Funk Forty Niner Jan 26 '15 at 14:25
  • thanks for help and I agree that the best way is to solve it by your self. I put the question here because of lack of time :/ so this reading I will do after office time – Luxqs Jan 26 '15 at 14:39
  • 1
    It should be `$from='From: $name <$email>' . "\r\n" . 'Return-path: $email";` FYI its good to be on white list on your server too. – Luxqs Feb 03 '15 at 18:38
  • yes the same day, but I got "banned" here (can not ask other questins) so I have to rias my reputation :D – Luxqs Feb 03 '15 at 19:20

0 Answers0