Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // The code below retrieves all the customer info from the database including customers email addresses.
  2. <?php
  3. while ($row = $result->fetch_assoc()){
  4. print "<tr>";
  5. print "<td>" . $row['TransactionID'] . "</td>";
  6. print "<td>" .$row['ItemName']."<br>" ."</td>";
  7. print "<td>" .$row['ItemQTY']."<br>" ."</td>";
  8. print "<td>" . $row['ItemAmount'] . "</td>";
  9. print "<td>" . $row['BuyerEmail'] . "</td>";
  10. print "<td ><a href='#sendemail'>Process</a></td>"; //Once this link is clicked, it should take me to the next code send an email the retrieved email.
  11.  
  12.  
  13. print "</tr>";
  14. }
  15. $mysqli->close();
  16.  
  17.  
  18. ?>
  19.  
  20. // The code below should trigger once i click "Process" and send an email to the customer.
  21. if (isset($_GET['sendemail'])){
  22.  
  23. require 'PHPMailer/PHPMailerAutoload.php';
  24.  
  25. $mail = new PHPMailer;
  26.  
  27. $mail->isSMTP();
  28. $mail->Host = 'smtp.gmail.com';
  29. SMTP servers
  30. $mail->SMTPAuth = true;
  31. authentication
  32. $mail->Username = '****@gmail.com';
  33. $mail->Password = '********';
  34. $mail->SMTPSecure = 'tls';
  35. `ssl` also accepted
  36. $mail->Port = 587;
  37.  
  38. $mail->setFrom('****@gmail.com', 'RANDOMNAME');
  39. $mail->addReplyTo('****@gmail.com', 'RANDOMNAME');
  40. $mail->addAddress('BuyerEmail');
  41.  
  42.  
  43. $mail->isHTML(true);
  44.  
  45. $bodyContent = '<h1>Our Valued Customer,</h1>';
  46. $bodyContent .= '<p>Your Order is ready for pick up!</p>';
  47.  
  48. $mail->Subject = 'RANDOMNAME';
  49. $mail->Body = $bodyContent;
  50.  
  51. if(!$mail->send()) {
  52. echo 'Message could not be sent.';
  53. echo 'Mailer Error: ' . $mail->ErrorInfo;
  54. }
  55. runsendemail();
  56.  
  57.  
  58.  
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement