mailing form send the mail to junk..code inside

Discussion in 'PHP' started by lucy92, Sep 30, 2012.

  1. #1
    Hello,
    I use a wordpress theme that has a mailing form, but when users send me email it goes to the HOTMAIL junk mail, here is the code for the php file..

    
      <?php
      		if(isset($_POST['submit'])) {
              error_reporting(E_NOTICE);
              function valid_email($str)
              {
              return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
    		     }
              if($_POST['name']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
              {
                  $to = preg_replace("([\r\n])", "", hexstr($_POST['receiver']));
    			  $from = preg_replace("([\r\n])", "", $_POST['email']);
    			  $subject = "Website contact message from ".$_POST['name'];
                  $message = $_POST['comment'];
    			  
    			  $match = "/(bcc:|cc:|content\-type:)/i";
    				if (preg_match($match, $to) ||
    					preg_match($match, $from) ||
    					preg_match($match, $message)) {
    				  die("Header injection detected.");
    				}
                  $headers = "From: ".$from."\r\n";
       			  $headers .= "Reply-to: ".$from."\r\n";
                 
            if(mail($to, $subject, $message, $headers))
                  {
                      echo 1; //SUCCESS
                  }
                  else {
                      echo 2; //FAILURE - server failure
                  }
              }
              else {
           	  echo 3; //FAILURE - not valid email
    
              }
    		  }else{
    			 die("Direct access not allowed!");
    		   }
    		   
    		    function hexstr($hexstr) {
    				  $hexstr = str_replace(' ', '', $hexstr);
    				  $hexstr = str_replace('\x', '', $hexstr);
    				  $retstr = pack('H*', $hexstr);
    				  return $retstr;
    				}
    
          ?>
    
    
    
    PHP:
    Thanks.
     
    lucy92, Sep 30, 2012 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    prasanthmj, Sep 30, 2012 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Set hotmail to not 'junk' email from your site.
     
    Rukbat, Oct 1, 2012 IP
  4. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    Perhaps your IP has been black listed or the content in the email is being detected as spam.
     
    NetStar, Oct 1, 2012 IP
  5. niveza.ppc

    niveza.ppc Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    My email id has been marked spam by few servers, can anyone tell me who are the email spam list service provider for Google, Yahoo & Rediff?? mail me on
     
    niveza.ppc, Oct 2, 2012 IP
  6. vcreationzz

    vcreationzz Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Technically, Hotmail is responsible for this, as they are the one handling incoming emails and marking them as spam.
     
    vcreationzz, Oct 2, 2012 IP
  7. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #7
    Send emails using SMTP, this way you are sure that your email will not be marked as spam almost all the times.
     
    ThePHPMaster, Oct 3, 2012 IP