Please help me in newsletter sending ,
this my code the problem is the mail is send to single person is going correctly ,if the same mail send to more number of persons getting wrong mail is going but the data display only in first mail ,the other mails getting decoded data please help me urgent,
In code i given comments for $mime_boundary i dont know its correct or not ,other wise please give me the code for newsletter for more number of peoples
thanks in advance

if(($_POST['group']<>'') && ($_POST['group']==0))
{
if($usrgroup='all')
{
$query="select email from cfair_adminusers order by admin_id";
$var=mysql_query($query);
while($arrayemail=mysql_fetch_array($var))
{
$emailid=$arrayemail['email'];
$to = $emailid;
$subject = $subject ;
$message=$message;
//$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
if($_FILES['filename']!='')
{
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
if(file_exists($tmp_name))
{

if(is_uploaded_file($tmp_name))
{

$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
}
}

$headers .= 'From:superadmin@fair.com' . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$headers .= 'Bcc: [email]admin@fair.com[/email]' . "\r\n";
'Reply-To: [email]sss@.solutin.com[/email]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(@mail($to, $subject, $message, $headers))
{
echo "Message Sent";
header("location:send_newsletter.php");
}
else
{
echo "Mail Not Sent";
}

}//while
}//if
}//if

Hi nathenastle,

Please take the time to read the forum rules. In particular, how to post code using code tags.

In response to your problems, I don't really understand your question sorry. What do you mean by "the other mails getting decoded data"? If you uncomment $mime_boundary, your Content-Type line looks like this:

Content-Type: multipart/mixed;\r\n boundary="==Multipart_Boundary_x<32-bit encrypted number>"x

Are you sure this is what you want?

try this please
changes are in red color

<?
if(($_POST['group']<>'') && ($_POST['group']==0))
{
if($usrgroup='all')
{
$query="select email from cfair_adminusers order by admin_id";
$var=mysql_query($query);
while($arrayemail=mysql_fetch_array($var))
{
$emailid=$arrayemail['email'];
$to .= $emailid.',';

$subject = $subject ;
$message=$message;
//$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
if($_FILES['filename']!='')
{
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
if(file_exists($tmp_name))
{

if(is_uploaded_file($tmp_name))
{

$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
}
}

$headers .= 'From:superadmin@fair.com' . "\r\n" ."MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed;\r\n" ." boundary=\"{$mime_boundary}\"";
$headers .= 'Bcc: admin@fair.com' . "\r\n".'Reply-To: sss@.solutin.com' . "\r\n" .'X-Mailer: PHP/' . phpversion();

if(@mail($to, $subject, $message, $headers))
{
echo "Message Sent";
header("location:send_newsletter.php");
}
else
{
echo "Mail Not Sent";
}

}//while
}//if
}//if 
?>

Thanks for your immediate replay,
My concept is how to send a newsletter for more number of mail ids ,according to my code it will go to one mailid not for more number of mailids if you understand my code or not ,other wise can you give any other code for sending newsletters to more number of mail ids

Thanks for your replay but its not working properly its not taking any files that too mail is going 3 times

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.