+ Reply to Thread
Results 1 to 6 of 6

Thread: php mail() code help

  1. #1
    wbaptist is offline x10Hosting Member wbaptist is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    21

    php mail() code help

    PHP mail() stopped working

    DeadBattery who has been helping me suggested that I post my code for sending emails up here in case there is something wrong with it. The code used to work fine, but mid Janurary it stopped working. Thanks for taking a look guys.

    PHP Code:
    <?php if(isset($_POST['submit'])) {
    $to "*********@worthingtonbaptistchurch.com";
    $selected $_POST['Email:'];
    $subject "Worthington Baptist Church Contact Form -- To: $selected";
    $messagesubject $_POST['messagesubject'];
    $name_field $_POST['name'];
    $email_field $_POST['email'];
    $message $_POST['message'];
    $body "To: $selected\n From: $name_field\n E-Mail: $email_field\n Subject: $messagesubject\n Message: $message";
    echo 
    "Your letter has been sent to the appropriate person. Thank You.";
    mail($to$subject$body);
    } else {
    echo 
    "Access denied.";
    }
    ?>
    Last edited by wbaptist; 02-25-2010 at 04:24 PM. Reason: Forgot to drop my real email address :-)

  2. #2
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: php mail() code help

    have you fixed this or do you still need help? you may want to try a different method all together. PHPMailer is pretty good.

  3. #3
    farscapeone's Avatar
    farscapeone is offline Community Advocate farscapeone is on a distinguished road
    Join Date
    Dec 2008
    Location
    Србија (Serbia)
    Posts
    1,166

    Re: php mail() code help

    First of all you have a big security problem with the script you are using. You geting $_POST data and pass it directly to your mail function. This is where hacker and come in. You have to use stripslashes() function to make sure all that "nasty" scripts won't come through.

    If it worked before then I guess there's nothing wrong with it. It may be that your script stopped working because mail server is down cos of all the updates going on now. It could also be that your PHP setting are not right.

  4. #4
    drf1229 is offline x10Hosting Member drf1229 is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    71

    Re: php mail() code help

    I've had problems with mail, as some messages don't go through. I've avoided this by using google's smtp server instead.
    Your 14 year old web developer. If I can do it, you can!
    My site
    My iPhone App

  5. #5
    wbaptist is offline x10Hosting Member wbaptist is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    21

    Re: php mail() code help

    Thanks for the reply I have been hopeing someone would help me. No, it still is not working.

    So to make the code hacker safe would I do this to all the varibles I pull from the $_POST?
    PHP Code:
    $selected =  stripslashes($_POST['Email:']); 
    PHPMailer does sound nice the way it can use a gmail account to send the mail I'll have to give it a try. Thanks for the help.

  6. #6
    wbaptist is offline x10Hosting Member wbaptist is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    21

    Re: php mail() code help

    I just tested PHPMailer using gmail and it works!!! Now all I need to find out is if the PHP code I posted above will keep hackers out?
    Last edited by wbaptist; 03-01-2010 at 08:42 PM.

+ Reply to Thread

Similar Threads

  1. Conformation e-mail code
    By troop968 in forum Free Hosting
    Replies: 1
    Last Post: 02-10-2010, 01:42 AM
  2. E-mail confomration code
    By troop968 in forum Free Hosting
    Replies: 1
    Last Post: 02-10-2010, 01:39 AM
  3. Replies: 1
    Last Post: 09-30-2009, 11:52 AM
  4. How to use send mail by php code ?
    By 10april in forum Programming Help
    Replies: 2
    Last Post: 09-15-2009, 08:14 PM
  5. PHP Mail Code Problem
    By Swiblet in forum Free Hosting
    Replies: 2
    Last Post: 11-04-2007, 09:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers