Jump to content

email php help!!


grlayouts

Recommended Posts

I want a script that will send an email to all my users in the database except staff..

however its not working!

 

anyone?

 


<?
include ("header.php");
$title = "email users"; 

if ($action == "send"){
$user=$_SESSION['user'];

$select=mysql_query("SELECT * FROM players WHERE user='$user'");
$p=mysql_fetch_object($select);

$i8n=mysql_query("SELECT * FROM players WHERE rank != 'Staff'");

$text=strip_tags($_POST['mass_msg']);

if(!$text){

}else{

while($object = mysql_fetch_object($i8n)){ 

$addy=$object[email];

$subject = "HoboTown Newsletter"; 
    $message = "Dear $object[user], 
<br>
    $text
<br>
    Thanks! 
    HoboTown Staff

E-Mail From $stat[user] Part Of The HoboTown Administration Team.<br>
If You See This Message Isnt From HoboTown Please Contact paul@designanyone.com  
     ";
    mail($addy, $subject, $message, 
        "From: <staff@hobotown.co.uk>")or die(mysql_error());

print "Message Sucessfully Sent To $object[user] - $object[email]<br>";
}
print "Done";
}
}

?>

<html>
<form method="post" action="newsletter.php?action=send">
Message To Send:<br> <textarea name="mass_msg" cols="40" rows="7" id="mass_msg"></textarea>
<br><input type="submit" value="E-Mail All Users">
</form>
</html>


Link to comment
Share on other sites

mail($addy, $subject, $message, "From: <staff@hobotown.co.uk>")or die(mysql_error());

 

Firstly, mysql_error() ONLY has to do with MYSQL functions.

mail() returns either true or false, based on if it was accepted for delivery.

 

$addy=$object; needs to be $addy=$object['email']; - same with the rest of your arrays[].

 

It may have gone into your spam folder. If it's not there, contact your webhost, and ask them for help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.