Advertisement
nendies

php mail

Feb 8th, 2019
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. <?php
  2. include '../koneksi.php';
  3. include "../classes/class.phpmailer.php";
  4.  
  5. $id=mysqli_real_escape_string($koneksi, $_GET['id']);
  6.  
  7. $query = mysqli_query($koneksi, "SELECT * FROM mkt_activity JOIN master_mkt ON mkt_activity.ID_MKT = master_mkt.ID_MKT JOIN master_customer ON mkt_activity.ID_CST = master_customer.AccNo JOIN dtl_activity ON mkt_activity.id = dtl_activity.id WHERE mkt_activity.id='$id'");
  8.  
  9. if ($query)
  10. {
  11. while ($result = mysqli_fetch_array($query))
  12. {
  13. $visit = $result['ID_VISIT'];
  14. $marketing = $result['MKT_NAME'];
  15. $company = $result['CompanyName'];
  16. $contact = $result['NAME_CONTACT'];
  17. $departement = $result['NAME_DEPT'];
  18. $purpose = $result['PURPOSE'];
  19. $model= $result['MODEL'];
  20.  
  21. $headmail = "Dear Mr. Edwin Indradjaja <br><br> Today I Visit " . $contact . ", Departement " . $departement . ", " . $company . ", For " . $purpose . " <br><br>Detail Order : <br><br>";
  22.  
  23. $footermail = " Detail Visit History, please open <a href= 'http://srp.pt-armstrong.co.id/newmodel/tampil_newmodel@@.php?id=" . $id . "'>Detail</a><br><br>Thank You <br> Best Regards <br><br><br>" . $marketing;
  24.  
  25.  
  26. }
  27.  
  28. $mail = new PHPMailer;
  29. $mail->IsSMTP();
  30. $mail->SMTPSecure = 'ssl';
  31. $mail->Host = "mail.google.com"; //host masing2 provider email
  32. $mail->SMTPDebug = 2;
  33. $mail->Port = 465;
  34. $mail->SMTPAuth = true;
  35. $mail->Username = "esales.ptai@gmail.com"; //user email
  36. $mail->Password = "12345678"; //password email
  37. $mail->SetFrom("nendies.pb@gmail.com","eSales Armstrong"); //set email pengirim
  38. $mail->Subject = "Visit Report " . $purpose . " : " . $model ; //subyek email
  39. $mail->AddAddress("esales@pt-armstrong.co.id"); //tujuan email
  40. $mail->AddCC("nendies@gmail.com"); //tujuan CC
  41. $mail->isHTML(true);//Set email to Format Html
  42.  
  43. $mail->Body = $headmail . "<table border=1>
  44. <tr>
  45. <th>No</th>
  46. <th>Part Code</th>
  47. <th>Model</th>
  48. <th>Qty Prod</th>
  49. <th>Life Time</th>
  50. <th>Qty/Month</th>
  51. <th>Start Mas Pro</th>
  52. <th>Remarks</th>
  53. </tr>";
  54.  
  55. $query = mysqli_query($koneksi, "SELECT * FROM dtl_activity LEFT JOIN mkt_activity ON dtl_activity.id = mkt_activity.id JOIN master_mkt ON mkt_activity.ID_MKT = master_mkt.ID_MKT JOIN master_customer ON mkt_activity.ID_CST = master_customer.AccNo WHERE mkt_activity.id='$id'");
  56.  
  57. $num=1;
  58. while ($result = mysqli_fetch_array($query))
  59. {
  60. $itemcode=$result['ITEM_CODE'];
  61. $model=$result['MODEL'];
  62. $qprod=$result['QTY_PRD'];
  63. $lifetime=$result['LIFE_TIME'];
  64.  
  65. if ($lifetime!=0) {
  66. $qmonth=$qprod/$lifetime;
  67. $qmonth=$qmonth;
  68. }
  69. else
  70. $qmonth="-";
  71.  
  72. $qmonth=round($qmonth,0);
  73.  
  74. $startmaspro=$result['START_MASPRO'];
  75. $remarks=$result['REMARKS'];
  76.  
  77. $mail->Body .= "
  78.  
  79. <tr>
  80. <td align='right'>" . number_format($num) . "</td>
  81. <td>" . $itemcode . "</td>
  82. <td>" . $model . "</td>
  83. <td align='right'>" . number_format($qprod) . "</td>
  84. <td align='right'>" . number_format($lifetime) . "</td>
  85. <td align='right'>" . number_format($qmonth) . "</td>
  86. <td align='right'>" . date('d-m-Y', strtotime($startmaspro)) . "</td>
  87. <td>" . $remarks . "</td>
  88. </tr>";
  89. $num++;
  90. }
  91. $mail->Body .= "</table><br><br>" . $footermail ;
  92.  
  93.  
  94. if($mail->Send())
  95. echo "Message has been sent ";
  96. else echo "Failed to sending message";
  97. echo
  98. "<script>alert('Success'),window.open('detail_newmodel.php?id=".$id."','_SELF')</script>";
  99.  
  100.  
  101. }
  102.  
  103. else
  104. {
  105. echo
  106. "
  107. <script>alert('Maaf Gagal Tambah Data'),window.open('detail_newmodel.php?id=".$id."','_SELF')</script>
  108. ";
  109.  
  110.  
  111. }
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement