SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help please!! Urgent! PHP form NOT going to inbox.

    For some reason I have this PHP form that I had put together which I thought was going to inbox which still is not. The form processes but every e-mail goes to the inbox. The only time it goes to the inbox is only if I'm launching it and testing the form through my PC. If somebody could help me fix this problem because this has been driving me stupid crazy. I had paid a local web company to put together the form and it seems it works but not sending to write location. This form is for my best friend / client website so that is why I sort of need it fixed ASAP. She's starting to get pretty impatient so. I also have the HTML form code just below.

    PHP Code:
    <?php

    $where_form_is
    ="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

    session_start();

    if( (
    $_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {

        if(
    $_POST['subject']=='1')

        {

            
    $to="kevra83@gmail.com";

           

        }

        
    $to="kevra83@gmail.com";

       

    $subject 'Form Submission';

        
    $message "Visitor  Message

                    First Name: " 
    $_POST['firstname'] ."\r\n""

                    Last Name: " 
    $_POST['lastname'] ."\r\n""

                    Phone Number: " 
    $_POST['phone'] ."\r\n""

                    Email Address: " 
    $_POST['email'] ."\r\n""

                    Comments.: " 
    $_POST['comment'] ."\r\n""

               

                       

                    Sent to you by contact form."
    ;

       

        
    $headers 'From: kevra83@gmail.com' "\r\n" .

        
    'X-Mailer: PHP/' phpversion();

    mail($to$subject$message$headers);

    include(
    "contact.html");

    }

    else {

    echo 
    "Invalid Captcha String, please resubmit form and type in the image.";

    }

    ?>
    HTML Code:
    <div id="left">
    
          <div id="contact_form">
    
            <h1>Contact </h1>
    
            <p>Please fill out the information below.</p>
    
            <form method="post" action="formm.php" name="Customer Service Form">
    
      <input type="hidden" name="subject" value="Customer Service Inquiry">
    
      <input type="hidden" name="redirect" value="../thankyou.php">
    
    <table width="550" border="0" align="center" cellpadding="0" cellspacing="6" class="style10">
    
      <tr>
    
        <td colspan="2"><b>*Denotes required fields:</b> </td>
    
      </tr>
    
      <tr>
    
        <td class="colorRed" colspan="2"></td>
    
      </tr>
    
      <tr>
    
        <td  colspan="2"> </td>
    
      </tr>
    
      <tr>
    
        <td width="319" ><div align="right"><b>*</b> First Name: </div></td>
    
        <td width="433" ><input type="text"  maxlength="40" size="18" value="" name="firstname" id="firstname" /></td>
    
      </tr>
    
     
    
      <tr>
    
        <td ><div align="right"><b>* </b>Last Name: </div></td>
    
        <td ><input type="text"  maxlength="40" size="18" value="" name="lastname" id="lastname" /></td>
    
      </tr>
    
     
    
      <tr>
    
        <td ><div align="right"><b>* </b>Phone Number: </div></td>
    
        <td ><input type="text"  maxlength="10" size="10" value="" name="phone" id="phone" /></td>
    
      </tr>
    
     
    
      <tr>
    
        <td ><div align="right"><b>* </b>Email Address: </div></td>
    
        <td >
    
          <input type="text"  maxlength="100" size="18" value="" name="email" id="email" />    </td>
    
      </tr>
    
      <tr>
    
        <td  colspan="2"> </td>
    
      </tr>
    
      <tr>
    
        <td><div align="right">Comments</div></td>
    
        <td><textarea cols="50" rows="8" wrap="virtual" maxlength="1000" name="comment" id="comment"></textarea></td>
    
      </tr>
    
      <tr>
    
        <td  colspan="2"> </td>
    
      </tr>
    
      <tr class="bodywhite_text">
    
        <td valign="top" class="bodytext3"><label class="formFieldQuestion">
    
          <div align="right">Type the image*&nbsp;<a class="info" href="#"><img src="tip_small.png" alt="For security purposes, please type the letters in the image." border="0" /></a><br />
    
            <img src="CaptchaSecurityImages.php" /> </div>
    
          </label></td>
    
        <td valign="top"><input id="captchaForm" name="security_code" class="mainForm" type="text"/></td>
    
      </tr>
    
      <tr>
    
        <td ></td>
    
        <td ><input name="Submit" type="submit" onclick="MM_validateForm('email','','RisEmail');return document.MM_returnValue" value="Submit" /></td>
    
      </tr>
    
    </table>
    
    </form></div>
    
          <div id="message_sent" style="display:none;">
    
            <h1>Your message has been sent</h1>
    
            <p>We'll contact you in a shortest possible time.</p>
    
            <p>You can now <a href="#" class="read-more">go back</a> to home page.</p>
    
          </div>
    
        </div>
    Last edited by Mittineague; Jun 12, 2013 at 11:45. Reason: please read the FAQ

  2. #2
    SitePoint Addict
    Join Date
    Oct 2008
    Location
    Virtual World is my location
    Posts
    311
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    There are a couple of reasons why php forms dont work. Overall I just glanced through the code and a couple of things you need to check are :
    1. The form submit says formm.php
    <form method="post" action="formm.php" name="Customer Service Form">
    So see if the php code is really under formm.php or is it form.php

    Second thing I note is that Header from code is a gmail email id. Now some servers restrict from header to the domain it is from which is rare, but I have seen some servers do not like any other domain. So in the from header try to put your domain email id like email @ thisisthedomainname .com and try and it should work

    Finally if the above two dont work, try removing the captcha code from the form and then trying. This option is really not needed and really if the captcha is wrong it should show a message, but maybe sometimes if captcha doesnot validate even then it might be creating issues.

    Try and let us know how you fixed it
    RecipesNext.com - recipes, kitchen queries, videos & more...
    BargainNext.com - coupons / deals / bargains / offers & more...

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The file name is formm.php with two mm's yes. It processes just fine but goes to junk e-mail box.

  4. #4
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,389
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    I suspect gmail is flagging the message as spam because the message claims to be coming from the same address that it's being sent to (kevra83@gmail.com), but the actual address it gets sent from will be determined by the webserver that's sending the email.

    Find the email in your junk folder and click on the small arrow to the right of the reply button, and from the dropdown menu choose 'Show original'. Gmail will open up the raw email (you'll be able to see all the email headers and such) and look for 'Return-Path' and see what it's set to.. this will probably be the address that the email is sent from.
    Try adding this address to the contacts for the account and see if that stops gmail from flagging the messages as spam.

  5. #5
    SitePoint Member
    Join Date
    May 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I managed to fix the problem. Freaking GoDaddy is freaking retarded and does not allow spam e-mail filters like yahoo, gmail, hotmail, aol, etc...to be used for processing forms send to. I guess they say you have to use your domain name e-mail address lol. I tested it with the domain e-mail address and it appears to work fine. I think It's time to close my godaddy account and go move to someone else like hostgator or someone.

  6. #6
    SitePoint Addict
    Join Date
    Oct 2008
    Location
    Virtual World is my location
    Posts
    311
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Nothing Freaking about it. Basically to avoid spam mails and to track spam mail, many hosting companies add the from header as the domain header. This is the case with most hosting companies including the other that you have mentioned. Hence this is not godaddy specific but there are many hosting companies that put in such restrictions. If you go to each hosting companies site and check their FAQs you will find this in most of them that they support only emails from theemailid @ thedomainname to prevent spam
    RecipesNext.com - recipes, kitchen queries, videos & more...
    BargainNext.com - coupons / deals / bargains / offers & more...

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    To webmasters and/or developers it can be aggravating. We know what we want the FROM to be.

    But to a hosting provider, they don't know if a site's forms are locked down or not and they don't want SPAM email being sent from their servers.

    I have seen many threads where the OP was getting SPAM from their contact form and were dismayed to learn it was being used to send SPAM because they didn't filter and sanitize user supplied input and it allowed header injection techniques to BCC others. (You are locking down your form aren't you?)

    If this is only for you then IMHO fretburner's suggestion to add the address to your white list i.e. "contacts" is probably the easiest thing.

    If this is for others eg. a newsletter, then you could ask them to add it to their white list. I have seen site's ask this, but I'm not sure how good of an idea it is to rely on users to know how to do this and actually do it.

    I have never used one, but AFAIK using a dedicated email service would solve the problem (and give other info like open rates), but for the added expense it might be overkill for your needs.

  8. #8
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Dedicated services are the way to go. Especially since mandrill is free for the first 12k emails a month. You send via json rather than mailto but that is easy to consume from anything these days.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •