PHP mail() not working

Status
Not open for further replies.

funchatx

New Member
Messages
25
Reaction score
0
Points
1
Hi, when I use PHP mail, it is not working. Here is my code that used to work until recently:

Code:
function add_user($user, $pass, $email){
$user = mysql_real_escape_string(htmlentities($user));
$pass = sha1($pass);
$email = mysql_real_escape_string(htmlentities($email));


$bio = "I just signed up!";
$memberstat = "Member";
$banned = "0";
$o = "Online";
$img = "http://i.imgur.com/XV16L.png";
$code = rand();


	  $to = $email;
	  $subject = "Account Verification Email";
	  $content = "
	hi, $user!


	Click on the link, or copy and paste the URL in your browser:
	
	http://www.domain.tk/verify.php?code=$code
	
	~Staff
	
     ";
     mail($to,$subject,$content);


mysql_query("INSERT INTO `table` (`username`, `password`, `email`, `banned`, `memberstat`, `bio`, `online`, `image`, `email_verif`) VALUES ('{$user}', '{$pass}', '{$email}', '{$banned}', '{$memberstat}', '{$bio}', '{$o}', '{$img}', '{$code}')");


}

The signup page code:

Code:
if (isset($_POST['username'],$_POST['password'], $_POST['repeat_password'], $_POST['email'])){
    $errors = array();


    if (empty($_POST['username'])){
      $errors[] = 'The username field is empty.';
    }
    if (empty($_POST['email'])){
      $errors[] = 'The email field is empty.';
    }
    if (empty($_POST['password']) || empty($_POST['repeat_password'])){
     $errors[] = 'The password field is empty.';
    }


    if ($_POST['password'] !== $_POST['repeat_password']){
      $errors[] = 'The passwords do not match';
    }


    if (user_exists($_POST['username'])){
      $errors[] = 'The username you entered already exists.';
    }




    if (empty($errors)){
      add_user($_POST['username'], $_POST['password'], $_POST['email']);
	  
		$suc123L = "Sucess! An email has been sent. If you don't see it, check your spam/junk folder.";




    }
}

The form code:

Code:
<form action="" method="POST">


<p>


<?php
if (empty($errors) === false){


?>


<ul>


<?php


foreach ($errors as $error){
   echo "<center><li>[$error]</li></center>";
}


?>


</ul>


<?


}


if(!empty($suc123L)){


?>
<center><b><?php echo $suc123L;?></b></center>
<?php
}
?>


</p>
<input type="text" name="username" placeholder="Username" maxlength="40" value="<?php if (isset($_POST['username'])){ echo htmlentities($_POST['username']); } ?>"><br><br>


<input type="password" name="password" placeholder="Password"><br><br>


<input type="password" name="repeat_password" placeholder="Repeat Password"><br><br>


<input type="text" name="email" placeholder="Email" value="<?php if (isset($_POST['email'])){ echo htmlentities($_POST['email']); } ?>"><br><br>


<input type="submit" value="Register">


</form>

I don't know why this stopped working. It used to work, but to broke all of a sudden.

Thanks for your help,
~funchatx
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I have a cron job that uses mail() once a day at 3am. The last one just arrived at 2pm, so my guess is that there was/is a backup in the mail queue. (Might be related to the recent 503 problems, causing lots of scripts to send out a lot of mails at the same time, backing up the system -- just a guess).
 

funchatx

New Member
Messages
25
Reaction score
0
Points
1
The email's that I sent with php earlier flooded my inbox. It seems that the 503 issue was the problem.
 
Last edited:
Status
Not open for further replies.
Top