Safe Mail

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Safe Mail

    in every email script tht i downloaded here, i saw no security....
    Code:
    mail($_POST['to'], $_POST['subject'], $_POST['message'], "From: ". $_POST['from']");
    smart person cn easily use it 4 own purpose....

    its nt tht he/she cn hack ur site but u c get in trouble..... THINK!!!
    it cn b easily type ur email in field From and send viruses 2 others.....


    so u cn use this 2 protect ur email script

    1st u need a simple function
    Code:
    function safemail ($header) {
    $header = str_replace ("\n", "\", $header); // changes every \n into nullbyte
    $header = str_replace ("\r", "\", $header); // changes every \r into nullbyte
    return $header;
    }
    and then use it 4 ur email script
    Code:
    $to = $_POST['to'];
    $subject = $_POST['subject'];
    $message = htmlspecialchars($_POST[&#39;message&#39;]);   //<------ c changes here
    $header = "From: ". safemail ($_POST[&#39;from&#39;]);        //<------ and here
    
    mail ($to, $subject, $message, $header);
    if sum1s knw more plz share it..
    sigpiceeeeerrr....

    #2
    Nice idea there bro

    also can use this

    Code:
    function is_from_valid($from) {
      if(eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $from)) return TRUE;
      else return FALSE;
    } 
    
    if (is_from_valid($from))
    {
    $mailok = "";
    }else{ 
    $mailok = "";
    echo "Unfortunately Your E-Mail is [b]Not A Valid Address[/b], Please Use Your Browsers Back Button And Re-Complete The Form";
    echo "
    <a href=\"index.php?action=a\">Back</a>
    ";
    echo "</div>";
    echo "</body>";
    echo "</html>";
    exit();
    }
    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      the best way is to use this:

      function tikrinti_emaila($emailas)
      {
      if(preg_match(&#39;/^\w[-.\w]*@(\w[-._\w]*\.[a-zA-Z]{2,}.*)$/&#39;, $emailas, $matches))
      {
      if(function_exists(&#39;checkdnsrr&#39;))
      {
      if(checkdnsrr($matches[1] . &#39;.&#39;, &#39;MX&#39;)) return true;
      if(checkdnsrr($matches[1] . &#39;.&#39;, &#39;A&#39;)) return true;
      }
      else
      {
      if(!empty($hostName))
      {
      if( $recType == &#39;&#39; ) $recType = "MX";
      exec("nslookup -type=$recType $hostName", $result);
      foreach ($result as $line)
      {
      if(eregi("^$hostName",$line))
      {
      return true;
      }
      }
      return false;
      }
      return false;
      }
      }
      return false;
      }

      Comment

      Working...
      X