+ Reply to Thread
Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By linkenpark51471
  • 1 Post By bkchris1913

Thread: why wont the mail send?

  1. #1
    linkenpark51471 is offline x10Hosting Member linkenpark51471 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    26

    Unhappy why wont the mail send?

    its for the login page and everything is sent to the database fine but the mail dosnt go out to the email and i have tried 2 diffrent emails

    PHP Code:
    if(isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["email"]))
    {
    $username mysql_real_escape_string(stripslashes($_POST["username"]));
    $password mysql_real_escape_string(stripslashes($_POST["password"]));
    $email mysql_real_escape_string(stripslashes($_POST["email"]));
    $fname mysql_real_escape_string(stripslashes($_POST["fname"]));
    $lname mysql_real_escape_string(stripslashes($_POST["lname"]));
    $number rand(52000);
    $message "Welcome to SaintMonopoly ";

    mail($email 'SaintMonopoly' $message "Please Dont Reply to this number go to Saintmonopoly.com" );

    $query "INSERT INTO members (username, password, image, email, fname, lname, suspended)
        VALUES('
    $username', '$password', 'images/nopic.jpg', '$email', '$fname', '$lname', 'yes')";
    $sql=$query;

    if (!
    mysql_query($sql))
      {
      die(
    'Error: ' mysql_error());
      }
    echo 
    "Your account has been created please verify your email then you can log in.";
    }
    mysql_close($con)
    ?> 
    Last edited by linkenpark51471; 10-05-2011 at 12:46 AM.
    dinomirt96 likes this.

  2. #2
    fluckermaster293's Avatar
    fluckermaster293 is offline x10Hosting Member fluckermaster293 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    5

    Re: why wont the mail send?

    Quote Originally Posted by linkenpark51471 View Post
    its for the login page and everything is sent to the database fine but the mail dosnt go out to the email and i have tried 2 diffrent emails

    PHP Code:
    if(isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["email"]))
    {
    $username mysql_real_escape_string(stripslashes($_POST["username"]));
    $password mysql_real_escape_string(stripslashes($_POST["password"]));
    $email mysql_real_escape_string(stripslashes($_POST["email"]));
    $fname mysql_real_escape_string(stripslashes($_POST["fname"]));
    $lname mysql_real_escape_string(stripslashes($_POST["lname"]));
    $number rand(52000);
    $message "Welcome to SaintMonopoly ";

    mail($email 'SaintMonopoly' $message "Please Dont Reply to this number go to Saintmonopoly.com" );

    $query "INSERT INTO members (username, password, image, email, fname, lname, suspended)
        VALUES('
    $username', '$password', 'images/nopic.jpg', '$email', '$fname', '$lname', 'yes')";
    $sql=$query;

    if (!
    mysql_query($sql))
      {
      die(
    'Error: ' mysql_error());
      }
    echo 
    "Your account has been created please verify your email then you can log in.";
    }
    mysql_close($con)
    ?> 
    maybe,u did something wrong in databse

  3. #3
    bkchris1913 is offline x10Hosting Member bkchris1913 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    2

    Re: why wont the mail send?

    I think you may have a couple of issues with your code.

    1. I think your suppose to use the '$to' variable to send out that email. I have always used it and have never had a problem. yet it might be good to try and see if it works that way.

    2. You need to add headers to your mail function also.
    3. There is something about the amount of parameters. 3 for localhost like xammp, but I think 4 for a live setting.
    4. Use an if statement to check if the message was sent before going on to do anything else. This will keep you from having entries goin thru with out mail going out. just place the mail() function in a variable and test the variable.
    5. You should probably add stripslashes, email preg_match and htmlentities to your variables to before sending em. I don't know if it really helps but better safe then sorry.

    in closing you could probably try each above to see if they help.
    karimirt47 likes this.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: why wont the mail send?

    Quote Originally Posted by bkchris1913 View Post
    1. I think your suppose to use the '$to' variable to send out that email. I have always used it and have never had a problem. yet it might be good to try and see if it works that way.
    No function cares about any variable name used to hold data passed to the function. That's largely the point of formal parameters.

    In fact, variable names don't really matter to programs. You can change a variable name to anything else as long as you a) do it consistently and b) don't use a variable name already in use within the scope of the variable. This is called "alpha conversion".

    Quote Originally Posted by bkchris1913 View Post
    2. You need to add headers to your mail function also.
    The header argument to mail is optional. However, setting a "From" header may help, as the mail is likely getting blocked in an attempt to prevent relaying.

    Quote Originally Posted by bkchris1913 View Post
    3. There is something about the amount of parameters. 3 for localhost like xammp, but I think 4 for a live setting.
    Parameters for what?

    Quote Originally Posted by bkchris1913 View Post
    5. You should probably add stripslashes, email preg_match and htmlentities to your variables to before sending em. I don't know if it really helps but better safe then sorry.
    htmlentities should only be used when outputting non-HTML data in an HTML document. stripslashes is only needed if magic quotes are enabled. Validating the e-mail address would be useful; the filter functions can accomplish that.

    The original code has other issues (information disclosure, use of die in a web script, use of the outdated mysql extension). I'm not going to bother going into details here; pick most any of my other posts at random and you'll likely find more information about these issues.
    Last edited by misson; 10-21-2011 at 09:33 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. conformation email wont send
    By g00s3 in forum Free Hosting
    Replies: 2
    Last Post: 04-18-2010, 11:28 PM
  2. PHP send mail - Unable to send to Yahoo! email addresses
    By royyuuki in forum Programming Help
    Replies: 7
    Last Post: 03-02-2010, 10:09 AM
  3. IPB User Registration Email wont send.
    By trgsmcadmin in forum Free Hosting
    Replies: 2
    Last Post: 01-08-2008, 11:11 PM
  4. Replies: 3
    Last Post: 12-03-2007, 08:56 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