Can't reply to email received from my contact page.

UPDATE

I found a work around:

If you recall, oddly, I would receive email from my contact page only if the php statement is written as:

[php]$field_name = $_POST[‘cf_name’];
$field_email = $_POST[‘cf_email’];
$field_email = $_POST[‘cf_phone’];
$field_message = $_POST[‘cf_message’];[/php]

for which as expected, I won’t receive the senders email address.

I finally came up with a set up as shown below :

[php]$field_name = $_POST[‘cf_name’];
$field_email = $_POST[‘cf_email’];
$field_email = $_POST[‘cf_phone’];
$field_phone = $_POST[‘cf_email’];
$field_message = $_POST[‘cf_message’];[/php]

Not only I still receive email, I now have the senders email though the data received looks like this:

[email protected]
From: hadi
E-mail: 408-123-4567
phone: [email protected]
Message:
testing Testing Testing…

The places for email and phone data reported is switched. I can not use the mail’s reply button to reply because it still uses phone number but I can reply by clicking on the email address sent as data item. Finally, after 11 days of being live, it woks now. I can officially order some business card.
I am supper happy!

I am grateful to all those who tried to help.

P.S. Since I got you all involved you may want to visit my site (http://hadiaghaeefineart.com) for the heck of it.

Well, it is still bad code, then. Your workaround may make it work, but, it is still badly formed and you really
should solve it so that the code is correct. My version that I gave you works perfectly on my server. But, that
is probably because it is on my server and not yours. I suspect that it is just the FROM tag. As I mentioned.
Your returned email shows the phone number in the wrong place and shows your server’s actual real address.
This should not be allowed to show inside an email.

Please post your workaround code. The HTML in one PHP tag and your PHP code in a second PHP tag so we can
review what is different from my working version. I am sure it is just something simple. Moving foward, you do
want your site to be secure and correctly programmed. (In my humble opinion!)

Hi Ernie, Thank you for still caring. Yes of course I want a safe web site.

I have pasted the contact.html and contact.php files in its entirety. No other files are involved with contact page except style sheet. Please keep in mind that this whole web site was put together while I was learning html and css. I am not sure of my project partner’s extent of php knowledge claim.

Here is the contact.html

[php]

Hadi Aghaee Fine Art
  <div id="logo1"> 

logo

<nav>
    <ul>
    <li class="hide"><a href="acrylic.html"> Acrylic Gallery</a></li>
    <li class="hide"><a href="digital.html">Digital Gallery</a></li>
  • Gallery
    		</ul></li>
            <li>  <a href='http://fineartamerica.com/profiles/hadi-aghaee/shop/all/all/all ' target="_blank" onclick="return confirm('You will be redirected to another site for print purchaces')">Shop</a> </li> 
    
  • Events
  • About
  • Contact
  •     </ul>
      </nav>
    
      </header>       
    
    <div id="wrapper">
    
      <section id="primary" style="padding: 0px 5% 0 5%;" >
    
     <div id="formstyle">
    
    <form action="contact.php" method="post">
    <div>
    <label class="desc" id="title1" for="cf_name">Full Name</label>
    <div>
      <input id="Field1" name="cf_name" type="text" class="field text fn" value="" size="8" tabindex="1">
    </div>
    
    Email
    Phone
    Message

    Get In Touch

    If you have any questions, comments, or would like to inquire about an original painting, please use the form provided here and I will get back to you as soon as possible.


    Thank you for visiting

      <div id="leftfooter">
        <p id="copyright"> The images and materials in this site are copyrighted by the site owner.   <br>
         © All Rights Reserved, unauthorized use is prohibited.  </p>  
        </div>
        
      <div id="rightfooter">
        <a href="https://www.facebook.com/HadiAghaeeFineArt" target="_blank"><img src="img/facebook.png" alt="facebook" class="social"></a>
         <a href="https://youtu.be/fJKYqnDIUTQ" target="_blank"><img src="img/youtube.png" alt="you tube" class="social"></a>
    <!--      <a href="#"><img src="img/pinterest.png" alt="pinterest" class="social"></a>  -->
          </div>
           
      </footer>
    
    [/php]

    Case 1: The php code that I started with: I receive visitor data but email is replace with phone#. Unable to reply.
    [php]<?php
    $field_name = $_POST[‘cf_name’];
    $field_email = $_POST[‘cf_email’];
    $field_email = $_POST[‘cf_phone’];
    $field_message = $_POST[‘cf_message’];

    $mail_to = ‘[email protected]’;
    $subject = 'Message from a site visitor '.$field_name;
    $body_message = 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'phone: '.$field_phone."\n";
    $body_message .= 'Message: '.$field_message;
    $headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    if ($mail_status) { ?>

    <?php[/php] [b]Case2: I won't receive any email at all.[/b] [php]$field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_phone = $_POST['cf_phone']; $field_message = $_POST['cf_message'];[/php] [b]Case 3: My workaround. I receive data. Still can't reply but senders email is available now in case I need to contact back.[/b] [php]$field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_email = $_POST['cf_phone']; $field_phone = $_POST['cf_email']; $field_message = $_POST['cf_message'];[/php] Thanks.

    Well, LOL, sometimes it is the simplest errors that cause the problems… In your code, you set the tab indexes
    so the user moves smoothly from field to field. But, in line #63, you duplicate an index. Indexes should be in
    order 1,2,3 not 1,3,3… That will cause a lot of minor issues in how the fields are handled. Might be the cause
    of your fields not loading correctly. So, I would first change the index#3 to index#2 (first one) and then change
    the PHP code to:
    [php]
    $field_name = $_POST[‘cf_name’];
    $field_email = $_POST[‘cf_email’];
    $field_phone = $_POST[‘cf_phone’];
    $field_message = $_POST[‘cf_message’];
    [/php]
    And, then retest and let us know what you get for a result…

    Hi Ernie, I changed the first tabindex3 to tabindex2 and changed the php code too but still did not help and I got no mail in my inbox. I had played around with these before too. At one point I made the Field#, Title# and tabindex# match and in order with no desired results. Right now, I kept the tabindex2 in html file and put back my workaround in php file. Still getting my workaround results.

    My gut feeling is that these two contact files are part of a more complex contact page that may have had more codes or even additional files. I believe my project partner has cut corners and codes as he deemed unnecessary to create the simplest contact page resulting to this problem. There are some ID’s and classes in the html form that I can not locate where they are defined in my web page directory.

    Well, to debug this, we need to know what is being sent to the mail function. To do that, replace this:
    [php]
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    [/php]
    With this:
    [php]
    echo "
    to: ".$mail_to;
    echo "

    subject: ".$subject;
    echo "

    headers: ".$headers;
    echo “

    incoming posted values:
    ”;
    print_r($_POST);
    die(“

    Done!
    ”);
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    [/php]
    Go to your page and enter all fields with dummy info, fill in all fields… Submit it and post what you get back.
    Perhaps then, we can find out what is being altered… This code is very simple and should not be changing if
    posted. But, I have seen the tab indexing cause weird issues…

    When using workaround code:

    [php]$field_name = $_POST[‘cf_name’];
    $field_email = $_POST[‘cf_email’];
    $field_email = $_POST[‘cf_phone’];
    $field_phone = $_POST[‘cf_email’];
    $field_message = $_POST[‘cf_message’];[/php]

                 ------------  Results  ------------
    

    to: [email protected]

    subject: Message from a site visitor Hadi

    headers: From: 408-123-4567 Reply-To: 408-123-4567

    incoming posted values:
    Array ( [cf_name] => Hadi [cf_email] => [email protected] [cf_phone] => 408-123-4567 [cf_message] => Testing echo results with workaround code… [saveForm] => Send )

    Done!
    In this case, data is echoed correctly, data is sent but phone/email are switched.


    When using supposedly proper code:

    [php]$field_name = $_POST[‘cf_name’];
    $field_email = $_POST[‘cf_email’];
    $field_phone = $_POST[‘cf_phone’];
    $field_message = $_POST[‘cf_message’];[/php]

                 -------------  Results  ----------------------
    

    to: [email protected]

    subject: Message from a site visitor Hadi

    headers: From: [email protected] Reply-To: [email protected]

    incoming posted values:
    Array ( [cf_name] => Hadi [cf_email] => [email protected] [cf_phone] => 408-123-4567 [cf_message] => Testing echo results with supposedly proper code… [saveForm] => Send )

    Done!
    In this case, data echoed correctly, but not sent.

    Again, this is all due to the FROM: in your email. For some reason, Yahoo is allowing the phone number to be
    used. I do not understand that. Unless that is due to you testing on a phone. Refresh my memory, your server
    is not on Gmail or Yahoo, correct? Therefore, to make the email go to Yahoo, the FROM needs to be a valid
    server address, not the one that it is coming from. I am a bit perplexed on why it lets you use the phone num
    for it… Hmmm, a test to validate that would be to rerun the second test with the correct code and just change
    the FROM to be the phone number… ( FROM: 408-123-4567 ) and see if it works. But, that is not a valid or
    permanent workaround because it is also not correct.

    Is your site hosted on Godaddy?

    My web host is GoDaddy, the 2 emails shown here are real working email addresses.

    My domain is registered with Cheapname. Both GoDaddy and Cheapname claim they have nothing to do with emails unless I have signed up for mailserver with them. They think it should go through the way it is and GoDaddy mail test script passes for them. This is just so puzzling.

    It’s nothing to do with Godaddy, it has to do with Yahoo, AOL, Gmail, Hotmail and a couple others that check
    the FROM address and make sure it was coming from your host account. You can use your workaround if you
    want to and when it fails sometimes down the way, come back and we can start over. Really depends on what
    you want the site to do in the future. Testing bad code with one or two email addresses does not make it fixed
    in my humble opinion. Try it with FROM: [email protected], where you use your server’s name and see if
    it goes thru as it should…

    FYI, along with my workaround code I changed

    [php]$headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";[/php]

    to say

    [php]$headers = 'From: '.$field_phone."\r\n";
    $headers .= 'Reply-To: '.$field_phone."\r\n";[/php]

    No mail came through at all.

    I think for the time being I will use this work around but at the same time I will continue searching for a better contact form to replace this one. Once again, I appreciate your help.

    Thanks.

    Sponsor our Newsletter | Privacy Policy | Terms of Service