I used to have a major problem on my old hosting package where emails from my website to yahoo/bt just disappeared into the ether. I have since changed hosts and re-formated my mail scripts to use phpmailer SMTP and all generally appears to be working much better.
However I seem to be receiving more and more complaints that people are requesting their username or password and not receiving the email (or the registration email) and I have no idea why. This time there doesn't appear to be any pattern with isps.
Has any had this problem and been able to solve it or can anyone suggest a solution?
In case it helps, the code for the forgotten password facility is below (I have received no indication of errors being generated):
$fail=0;
$fail_reason='';
if (!empty($_POST['button_submit']) && isset($_POST['username']))
{
$auth_obj=new auth;
$auth_obj->username=mysql_real_escape_string(trim(strtolower($_POST['username'])));
$auth_obj->getuser();
$email=$auth_obj->user_email;
$username=$auth_obj->username;
if (!empty($username))
{
$user_auth=generate_password();
$pwd=sha1($user_auth);
$obj_db=new database;
$obj_db->connect();
$sql=mysql_query("SELECT user_id FROM users WHERE username='$username'");
$query=mysql_fetch_array($sql);
if (!empty($query['user_id'])) {
mysql_query("UPDATE users SET user_auth='$pwd' WHERE username='$username'");
}
else {
header ("location: forgot_user.php?user_fail=1");
}
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = SMTP_HOST;
$mail->Port = SMTP_PORT;
$mail->SMTPAuth = true;
$mail->Username = SUPPORT_USERNAME;
$mail->Password = SUPPORT_PASSWORD;
$mail->FromName = FROM_NAME;
$mail->From = SUPPORT_USERNAME;
$mail->IsHTML(true);
$mail->AddAddress($email);
$mail->Subject = 'Simply Canine Account';
$mail->Body = "<p>Your Simply Canine account password has been reset to:</p>";
$mail->Body .= "<p>".$user_auth."</p>";
$mail->Body .= "<p>Please go to http://www.simplycanine.co.uk/login.php to login. You may also change your password to something more memorable if required.</p>";
if(!$mail->Send()) {
echo "Error sending: " . $mail->ErrorInfo;
} else {
$success_message="<p>An e-mail containing your new password has been sent to: <strong>$email</strong></p>";
$success_message.="<p>Once received, please <a href=\"/login.php\">login</a> again.</p>";
}
}
else
{
$fail=1;
$fail_reason='Your username could not be found, please try again.';
}
}
I have tested all the basics and get no problems or errors.