I wish I could give a better title than "mail() problem," but that's really all I've got.
I started using PHP AGTC-Membership System v1.0a (a script I found somewhere but has a homepage at agtc.co.uk) which worked great once I got it going. It has a built in email system to send a message to new users. I wanted an email confirmation system to make sure the user's email is valid so I modified it a little (sends the user's email and encrypted password in a link, user clicks link, php page takes two variables and checks them in the database and then activates the account if they exist, but that isn't really important) and it worked great for a while. I tested it a dozen or so times, and some of my friends signed up on my page after that and all got the email and confirmed it fine.
Two or so weeks later, the emails stopped going out. People would try to create a new account and would never get an email. Since then I've tried it a few more times and found that it just randomly (its random as far as I can tell) chooses which emails to send and which to just discard.
Here is the adduser file:
<?php
// *************************************************************************************************
// Title: PHP AGTC-Membership system v1.0a
// Developed by: Andy Greenhalgh
// Email: andy@agtc.co.uk
// Website: agtc.co.uk
// Copyright: 2005(C)Andy Greenhalgh - (AGTC)
// Licence: GPL, You may distribute this software under the terms of this General Public License
// *************************************************************************************************
//
include("config.php");
include("check.php");
echo $msg;
$username = "";
$userpass = "";
$userlevel = "";
if(isset($_POST['Submit']))
{
$username = $_POST['username'];
$userpass = md5($_POST[userpass]);
$userlevel = $_POST['userlevel'];
$dt = date("Ymd");
$gra = getenv("REMOTE_ADDR");
// CHECK FOR DUPLICATE
$result = mysql_query("Select * from login_table",$con);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$n++;
if ($username == $row['user_name']) {$_GET['userid'] = "";
header("Location: adduser.php?msg2=true");
}}
if(!isset($_GET['userid']))
{
$result = mysql_query("Insert into login_table(user_name,user_pass,user_level,date,user_ip)
values('$username','$userpass','$userlevel','$dt','$gra')");
$msg2 = "";
$msg3 = "";
$msg = "An email has been sent to the specified address which you should receive shortly.
You must click a link in the email to confirm the address is valid before your
account will be activated.";
include "send.php";
}
}
?>
And the send file:
<?php
// *************************************************************************************************
// Title: PHP AGTC-Membership system v1.0a
// Developed by: Andy Greenhalgh
// Email: andy@agtc.co.uk
// Website: agtc.co.uk
// Copyright: 2005(C)Andy Greenhalgh - (AGTC)
// Licence: GPL, You may distribute this software under the terms of this General Public License
// *************************************************************************************************
//
include "config.php";
// DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW WHAT YOU ARE DOING
if ($username == "" or $userpass == ""){header("Location: adduser.php?msg3=true");}
$email = $username;
if (!isset($email)) {
echo "Error, Please re-send $username" ;
}
$todayis = date("l, F j, Y, g:i a") ;
$subject = $emailSubject;
$message = " $todayis [EST] \n
From: $sendersName ($sendersEmail)\n
Comment: $sendersComment \n
This email was automatically sent to this address when a new account was created at OutBy9.com.
If you did not try to create an account at OutBy9.com, please do not respond to this email and delete it.
To confirm your registration, you must click on the following link:
http://www.outby9.com/beta_test/more/confirm_email.php?email=$email&pass=$userpass
After clicking on the link, you will be a member of OutBy9.com and will be able to log in.
Thank you for joining the our community.
";
$from = "From: $sendersEmail";
if ($email != "") {
mail($email, $subject, $message, $from);
}
?>
$sendersName, $sendersComment, and $sendersEmail are all contained in config.php and no other variables overlap from that file.
I'm hoping there is just something I'm missing. If that's not the problem, any advice on where to start looking (server, php.ini, etc) for how to fix this would be greatly appreciated.
Since, from my understanding, the mail functions opens an SMTP socket for each message and then closes it, could it be leaving the socket open for too long so that no new messages get sent until it is closed? I know very little about SMTP, as may be evident from my terminology, so I really don't know what is going on here.