Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How safe is PHP mail from spam?

  1. #1
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default How safe is PHP mail from spam?

    Recently I have been using the email riddler at DD instead of CGI mail forms because I found the latter resulted in too much spam.

    Today I read my first PHP tutorial and discovered PHP mail. What I am wondering if whether it is worth using it, or whether I am better of using the email riddler. What do you think?

    The basic script that I am thinking about using will be something like below. Please let me know if there is any you think I need to add or subtract to protect against SPAM. (You will notice that I haven't included my real email address below - I am completely paranoid about SPAM!)
    Code:
    <html>
    <body><?php
    function spamcheck($field)
      {
    //eregi() performs a case insensitive regular expression match
      if(eregi("to:",$field) || eregi("cc:",$field)) 
        {
        return TRUE;
        }
      else
        {
        return FALSE;
        }
      }//if "email" is filled out, send email
    if (isset($_REQUEST['email']))
      {
      //check if the email address is invalid
      $mailcheck = spamcheck($_REQUEST['email']);
      if ($mailcheck==TRUE)
        {
        echo "Invalid input";
        }
      else
        { 
        //send email
        $name = $_REQUEST['name'] ; 
        $email = $_REQUEST['email'] ; 
        $subject = $_REQUEST['subject'] ;
        $dates = $_REQUEST['dates'] ;
        $message = $_REQUEST['message'] ;
        mail("name@myemail.com", "$subject",
        "$message\nDates we would like to book: $dates\n", "From: $name <$email>" );
        echo "Thank you for using our mail form $name";
        }
      }
    
    
    else
    //if "email" is not filled out, display the form
      {
      echo "<form method='post' action='mailform2.php'>
      Name: <input name='name' type='text' /><br />
    Email: <input name='email' type='text' /><br />
    Dates: <input name='dates' type='text' /><br />
      Subject: <input name='subject' type='text' /><br />
      Message:<br />
      <textarea name='message' rows='15' cols='40'>
      </textarea><br />
      <input type='submit' />
      </form>";
      }
    ?></body>
    </html>
    Looking forward to reading your thoughts.

    Rob

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    if you have a DB with the ip addresses and The # of times a day the person mails you, you'll be able to identify problem users. You could also use a randomized php Pic for verification
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Or a login of some sort.

    An open access form could be abused quite easily.

    The above tips can help, though.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your reply.

    Quote Originally Posted by boxxertrumps View Post
    You could also use a randomized php Pic for verification
    Sounds interesting. Do you know where I might find an idiots guide that shows me how to do this. (Bearing in mind that I only read my first php tutorial today!)

    I did a quick google search but could follow the instructions that I found.

    Rob

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's called "CAPTCHA"... acronym for something. There are quite a few recent threads about it... take a look around the php section (and "other" and perhaps "html"... not sure where they all were).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    CAPTCHA = Completely Automated Public Turing Test to Tell Computers and Humans Apart


    They left out some letters, of course... CAPTTTTCAHA was a little much I guess

    If they used all the letters though they could have Captain Caveman as their icon!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your replies. I found an idiots guide to captcha at:

    http://www.captcha.biz/captcha-explained.html

    I've uploaded the test file to www.vweekender.co.uk/testcaptcha/start.html

    but it's not working. Is this a problem with the code or the server?

    Rob

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The code.

    If you search, you'll find a thread I've posted on how to make a "good" CAPTCHA. However, I think I may have been a little misleading in this thread. Simply put, there is no such thing as a good CAPTCHA. CAPTCHA-breaking programs have advanced a level on which the only totally reliable way to fool a bot is to make a CAPTCHA that even humans can't read.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by robertsaunders View Post
    Recently I have been using the email riddler at DD instead of CGI mail forms because I found the latter resulted in too much spam.
    Was the spam actually generated using the form, or was it just sent to the same mailbox?

    Today I read my first PHP tutorial and discovered PHP mail.
    Using PHP is no different from using CGI. CGI is just a means for a Web server to communicate with a process for the purposes of receiving and responding to requests. In fact, PHP comes with an executable that uses the CGI model.

    Mike

  10. #10
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mwinter View Post
    Was the spam actually generated using the form, or was it just sent to the same mailbox?
    It was sent to the same mail box.

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
  •