views:

9

answers:

0

I m using phpmailer and when i send newsletter i m just getting 0kb file size, Could anybody help me plz

<?php
require_once("dbconnect.php");
require("class.phpmailer.php");
$mail = new PHPMailer();


$mail->IsMail();
$mail->From     = "[email protected]";
$mail->FromName = "mywebsite";
$mail->Host     = "localhost";

$chkval=$_REQUEST["chkmembers"];
$nid=$_POST['nid'];
$newsletter=mysql_query("SELECT * FROM tbl_newsletter WHERE nid='$nid'");
$cnews=mysql_num_rows($newsletter);
$newslettersubject=mysql_result($newsletter,0,"subject");
$newsletterbody=mysql_result($newsletter,0,"newsletter");
$file_name=mysql_result($newsletter,0,"file_name");

$body='';
//get all the products associated with this newsletter

$body=html_entity_decode($newsletterbody);
?>
<?php 
if(!empty($_REQUEST["mailtype"]) && $_REQUEST["mailtype"]=="manual")
{
   $mailsubject=$newslettersubject;
   $mailbody=$newsletterbody;
   $from="[email protected]";
   $to=$_POST["txtmanualnews"];
   $chkarr=explode(",",$to);
   /*$tomail=$chkarr;*/
   //check for attachment
  $uploadDir='../download/attachment';
  $attach=$_FILES['attach']['name'];
  $attachfile='../download/'.$file_name;
  $path=$uploadDir.$attach;

   foreach($chkarr as $toemail)
   {
    $mail->Body  = $body;
    $mail->Subject = $mailsubject;
    $mail->AddAddress($toemail,'');

    //$mail->AddAttachment($path, $attach,'base64','image/jpeg');
    $mail->AddAttachment($path, $file_name,'base64','image/jpeg');
     if(!$mail->Send())
     echo "error sending to".$toemail." <br>";

   else
   {
    echo "send mail succesfully !";
    echo "<script>location.href='index.php?function=newsletter&list'</script>";
    }
    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();
   }
}
?>