Hi there.
I need some help.
I have a mail script that seems to be faulty. I have a form that shows lots of people and their email addresses and we check boxes to choose the people to send the mail to.
When the message is written, it goes to this script below. The script checks who is on the list, sends the message to them and records in another table, who the message was sent to.
It seems that the last couple of times that we've used this some people have not received the emails. I can't find a pattern and because there are lots of people on the list (maybe 200), I can't call and ask everyone if they got the email.
I have a few ideas, but I don't know... Maybe...
- ... one of the addresses was not an email address, so it failed and the script stopped.
- ... some of the data being put into the database was odd (maybe unusual characters, which happens sometimes because we have Japanese as well as English input).
- ...the list was to long and the script timed out.
- ...there's a mistake in the script.
- ...my mail is being blocked/filtered by anti-spam stuff (though it is not spam).
Any help would be appreciated.
Cheers.
PHP Code:
if (isset($_POST['mlmessage'])) {
$subject=$_POST['mlsub'];
$message=$_POST['mlmessage'];
$mdate=mktime();
mysql_query("INSERT INTO mlmessage (message,mdate,subject) VALUES ('$message',$mdate,'$subject')");
$ml_id=mysql_result(mysql_query("SELECT id FROM mlmessage WHERE message='$message'"),0);
$addresses=array();
$q=mysql_query("SELECT email,id FROM students WHERE e1onlist=1");
while ($r = mysql_fetch_assoc($q)){
array_push($addresses,array($r['email'],$r['id']));
}
$q=mysql_query("SELECT email2,id FROM students WHERE e2onlist=1");
while ($r = mysql_fetch_assoc($q)){
array_push($addresses,array($r['email2'],$r['id']));
}
$from_email="us@our-site.com";
$from_name="us";
foreach($addresses as $address) {
$email=$address[0];
$stu_id=$address[1];
mysql_query("INSERT INTO mlmessage_who (stu_id, message_id, email) VALUES ('$stu_id','$ml_id','$email')");
$message=stripslashes($message);
sendMail($email, $subject, $message, $from_email, $from_name);
}
header("Location: http://$ipaddress/path/index.php?page=maillistmail&mess=sent");
}