Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- //Load Composer's autoloader
- require 'vendor/autoload.php';
- $mail = new PHPMailer(true);
- $order_list = json_decode($_POST['order_list'], true);
- $customer_details = json_decode($_POST['customer_name'],true);
- // var_dump($order_list);
- // echo "<br>";
- // var_dump($customer_details);
- // echo "<br>";
- // var_dump($customer_details['name']);
- $list_item='';
- foreach($order_list as $x)
- {
- $name = $x['name'];
- $quantity = $x['quantity'];
- $amount = $x['amount'];
- $list_item.="<tr>
- <td> ".$name."</td>
- <td>".$quantity."</td>
- <td>".$amount."</td>
- </tr>";
- }
- // Passing `true` enables exceptions
- try {
- //Server settings
- // $mail->SMTPDebug = 2; // Enable verbose debug output
- // $mail->isSMTP(); // Set mailer to use SMTP
- // $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- // $mail->SMTPAuth = true; // Enable SMTP authentication
- // $mail->Username = 'alexmanjaly22@gamil.com'; // SMTP username
- // $mail->Password = ''; // SMTP password
- // $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- // $mail->Port = 465; // TCP port to connect to
- // $mail->AddAddress("alexmanjaly22@gmail.com");
- // $mail->FromName = "ax22";
- // // //Recipients
- // $mail->setFrom('localhost', 'Mailer');
- // $mail->addAddress('alexmanjaly22@gmail.com', 'Joe User'); // Add a recipient
- // $mail->addAddress('ellen@example.com'); // Name is optional
- // $mail->addReplyTo('info@example.com', 'Information');
- // $mail->addCC('cc@example.com');
- // $mail->addBCC('bcc@example.com');
- // //Attachments
- // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- // $mail->isHTML(true); // Set email format to HTML
- // $mail->Subject = 'Here is the subject';
- // $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- // $mail->send();
- $to = "alexmanjaly22@gmail.com";
- $subject = "Burgerspace";
- $message = "
- <html>
- <head>
- <title>HTML email</title>
- </head>
- <body>
- <p>BurgerSpace Orderlist</p>
- <label>Name:".$customer_details['name']."</label><br>
- <label>Name:".$customer_details['email']."</label><br>
- <label>Name:".$customer_details['phone']."</label><br>
- <label>Name:".$customer_details['address']."</label><br>
- <hr></hr>
- <table>
- <thead>
- <tr>
- <th>Item</th>
- <th>Quantity</th>
- <th>Price</th>
- </tr>
- </thead>
- ".$list_item."
- <thead>
- <tr>
- <th colspan='1'></th>
- <th>Total</th>
- <th></th>
- </tr>
- </thead>
- </table>
- </body>
- </html>
- ";
- // Always set content-type when sending HTML email
- $headers = "MIME-Version: 1.0" . "\r\n";
- $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
- // More headers
- $headers .= 'From:contact@burgerspace.in' . "\r\n". "Reply-To: replyto@example.com",
- "X-Mailer: PHP/" . PHP_VERSION;
- if (mail($to,$subject,$message,$headers)) {
- echo 'Message has been sent';
- }else{
- echo 'Message sent error';
- }
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- ?>
Add Comment
Please, Sign In to add comment