Hi, is there anyone can help me with my problem ? i will appreciate it, try to solve it myself with all my knowledge but it just won’t work.
My Problem is i want to send email to all my registered members through my site admin panel. it work well if i send it to specific user, but it won’t work when i send to all. Appreciate and thanks to anyone which can help me.
id ,m_userid ,m_password ,m_email ,datejoin , dateexpire ,fee ,sitename ,siteurl ,description ,Referral ,status ,vcode
email.php where i enter i choose the option to send
<?php
include "../conn.php";
include "logs.php";
$sql = "SELECT * FROM members order by id";
$rec = mysql_query($sql) or die(mysql_error());
while($datas = mysql_fetch_array($rec)){
$users .= "<option value='$datas[m_email]'>$datas[m_userid]</option>";
}
$body = "<form method='post' action='sendemail.php'>
<table width = '94%' cellpadding='4'>
<tr>
<td>Send email to</td>
<td><select name='email'><option value='all' selected>All</option>$users</select></td>
</tr>
<tr>
<td>Email Subject</td>
<td><input type='text' name='subject' size='50'></td>
</tr>
<tr>
<td valing='top'>Email body</td>
<td><textarea name='body' rows='10' cols='45'></textarea></td>
</tr>
<Tr>
<td colspan='2' align='center'><input type='submit' name='submit' value='Send!'></td>
</tr>
</table>
</form>
";
include "template.php";
?>
sendemail.php where it start send email.
<?php
include "../conn.php";
include "logs.php";
$headers = "MIME-Version: 1.0
";
$headers .= "Content-type: text/plain; charset=iso-8859-1
";
$headers .= "From: \"$domain\" <noreply@$domain>
";
$headers .= "Reply-To: \"$domain\" <noreply@$domain>
";
$headers .= "X-Mailer: PHP's mail() Function
";
if($_POST[email]=="all"){
$sql = "SELECT * FROM members order by id";
$rec = mysql_query($sql) or die(mysql_error());
echo "Please wait while sending the emails";
$body .= "Email sending complete...";
while($datas = mysql_fetch_array($rec)){
$emailmessage = "Dear $datas[m_userid]:
$_POST[body]
Best Regards
$domain
Admin";
mail ("$datas[email]","$_POST[subject]","$emailmessage","$headers");
}
$body = "Email have been sent to all your members...";
}else{
$emailmessage = "Dear member:
$_POST[body]
Best Regards
$domain
Admin";
mail ("$_POST[email]","$_POST[subject]","$emailmessage","$headers");
$body = "Email have been sent to $_POST[email]";
}
include "template.php";
?>