endrasgusti

Untitled

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