why wont the mail send?

linkenpark51471

New Member
Messages
27
Reaction score
0
Points
0
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:
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(5, 2000);
$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:

fluckermaster293

New Member
Messages
5
Reaction score
0
Points
0
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:
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(5, 2000);
$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 :frown:
 

bkchris1913

New Member
Messages
2
Reaction score
0
Points
0
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.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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".

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.

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?

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:
Top