Guest User

Untitled

a guest
Oct 30th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. use PHPMailer\PHPMailer\Exception;
  6. //Load Composer's autoloader
  7. require 'vendor/autoload.php';
  8.  
  9. $mail = new PHPMailer(true);
  10.  
  11. $order_list = json_decode($_POST['order_list'], true);
  12. $customer_details = json_decode($_POST['customer_name'],true);
  13. // var_dump($order_list);
  14. // echo "<br>";
  15. // var_dump($customer_details);
  16. // echo "<br>";
  17. // var_dump($customer_details['name']);
  18.  
  19. $list_item='';
  20.  
  21. foreach($order_list as $x)
  22. {
  23. $name = $x['name'];
  24. $quantity = $x['quantity'];
  25. $amount = $x['amount'];
  26.  
  27. $list_item.="<tr>
  28.  
  29. <td> ".$name."</td>
  30. <td>".$quantity."</td>
  31. <td>".$amount."</td>
  32.  
  33. </tr>";
  34.  
  35. }
  36.  
  37. // Passing `true` enables exceptions
  38. try {
  39. //Server settings
  40.  
  41. // $mail->SMTPDebug = 2; // Enable verbose debug output
  42. // $mail->isSMTP(); // Set mailer to use SMTP
  43. // $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  44. // $mail->SMTPAuth = true; // Enable SMTP authentication
  45. // $mail->Username = 'alexmanjaly22@gamil.com'; // SMTP username
  46. // $mail->Password = ''; // SMTP password
  47. // $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  48. // $mail->Port = 465; // TCP port to connect to
  49.  
  50. // $mail->AddAddress("alexmanjaly22@gmail.com");
  51.  
  52. // $mail->FromName = "ax22";
  53. // // //Recipients
  54. // $mail->setFrom('localhost', 'Mailer');
  55. // $mail->addAddress('alexmanjaly22@gmail.com', 'Joe User'); // Add a recipient
  56. // $mail->addAddress('ellen@example.com'); // Name is optional
  57. // $mail->addReplyTo('info@example.com', 'Information');
  58. // $mail->addCC('cc@example.com');
  59. // $mail->addBCC('bcc@example.com');
  60.  
  61. // //Attachments
  62. // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  63. // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  64.  
  65.  
  66. // $mail->isHTML(true); // Set email format to HTML
  67. // $mail->Subject = 'Here is the subject';
  68. // $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  69. // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  70.  
  71. // $mail->send();
  72.  
  73. $to = "alexmanjaly22@gmail.com";
  74. $subject = "Burgerspace";
  75.  
  76. $message = "
  77. <html>
  78. <head>
  79. <title>HTML email</title>
  80. </head>
  81. <body>
  82. <p>BurgerSpace Orderlist</p>
  83. <label>Name:".$customer_details['name']."</label><br>
  84. <label>Name:".$customer_details['email']."</label><br>
  85. <label>Name:".$customer_details['phone']."</label><br>
  86. <label>Name:".$customer_details['address']."</label><br>
  87. <hr></hr>
  88. <table>
  89. <thead>
  90. <tr>
  91. <th>Item</th>
  92. <th>Quantity</th>
  93. <th>Price</th>
  94. </tr>
  95. </thead>
  96.  
  97. ".$list_item."
  98.  
  99. <thead>
  100. <tr>
  101. <th colspan='1'></th>
  102. <th>Total</th>
  103. <th></th>
  104. </tr>
  105. </thead>
  106.  
  107. </table>
  108. </body>
  109. </html>
  110. ";
  111.  
  112. // Always set content-type when sending HTML email
  113. $headers = "MIME-Version: 1.0" . "\r\n";
  114. $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  115.  
  116. // More headers
  117. $headers .= 'From:contact@burgerspace.in' . "\r\n". "Reply-To: replyto@example.com",
  118. "X-Mailer: PHP/" . PHP_VERSION;
  119.  
  120. if (mail($to,$subject,$message,$headers)) {
  121. echo 'Message has been sent';
  122. }else{
  123. echo 'Message sent error';
  124. }
  125.  
  126.  
  127. } catch (Exception $e) {
  128. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  129. }
  130.  
  131. ?>
Add Comment
Please, Sign In to add comment