Advertisement
endrasgusti

Untitled

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