Advertisement
endrasgusti

Untitled

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