endrasgusti

Untitled

Nov 6th, 2017
1,298
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require '../phpmailer/class.phpmailer.php';
  2.  
  3. $mail = new PHPMailer(true);
  4.  
  5. $body .="<table border='1'>";
  6. $body .="<tr>";
  7.     $body .="<td>No</td>";
  8.     $body .="<td>nama</td>";
  9.     $body .="<td>email</td>";
  10.     $body .="<td>kegiatan</td>";
  11.  $body .="</tr>";
  12.  
  13. $i=1;
  14. $email='';
  15. while ($row_spc = mysql_fetch_assoc($spc)){
  16. if($email!=$row_spc['email']){ 
  17. $mail      = new PHPMailer(true);
  18.    $body .="<tr>";
  19.       $body .="<td>".$i."</td>";
  20.       $body .="<td>".$row_spc['nama']."</td>";
  21.       $body .="<td>".$row_spc['email']."</td>";
  22.       $body .="<td>".$row_spc['kegiatan']."</td>";
  23.      $body .="</tr>";
  24.      if($i!=1){
  25.          
  26. $mail->IsSMTP();                           // tell the class to use SMTP
  27.  
  28. $mail->SMTPAuth   = true;                  // enable SMTP authentication
  29.  
  30. $mail->SMTPSecure = 'tls';
  31.  
  32. $mail->Port  = 587;                    // set the SMTP server port
  33.  
  34. $mail->Host  = 'smtp.gmail.com'; // SMTP server
  35.  
  36. $mail->Username   = 'xxxxxx@gmail.com';     // SMTP server username
  37.  
  38. $mail->Password   = 'xxxxxxxx';            // SMTP server password
  39.  
  40. //$mail->IsSendmail();  // tell the class to use Sendmail
  41.  
  42. $mail->AddReplyTo('xxxxxxxx@gmail.com');
  43.  
  44. $mail->From   = 'xxxxxxxx@gmail.com';
  45.  
  46. $mail->FromName   ='xxxxx';
  47.  
  48. $to = $row_spc['email'];
  49.  
  50. $mail->AddAddress($to);
  51.  
  52. $mail->Subject  = 'report sales';
  53.  
  54. //$mail->AltBody    = “To view the message, please use an HTML compatible email viewer!”;
  55.  
  56. // optional, comment out and test
  57.  
  58. //$mail->WordWrap   = 80; // set word wrap
  59.  
  60. $mail->MsgHTML($body);
  61.  
  62. $mail->IsHTML(true); // send as HTML
  63.  
  64. $mail->Send();
  65.  
  66. echo 'Message has been sent.';       
  67.  
  68.      }
  69.          
  70.         $email=$row_spc['email'];
  71.    $i++;
  72.   }
  73.   else {
  74.      $body .="<tr>";
  75.      $body .="<td></td>";
  76.      $body .="<td></td>";
  77.      $body .="<td></td>";
  78.       $body .="<td>".$row_spc['kegiatan']."</td>";
  79.      $body .="</tr>";
  80.      
  81.   }
  82.  
  83. }
  84.     $body .="</table>";
  85.  
  86. ?>
  87. </p>
  88. <p>&nbsp;</p>
RAW Paste Data