Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. require '../../../PHPMailer-master/PHPMailerAutoload.php';
  2.  
  3. $mail = new PHPMailer(true);
  4. try {
  5. $mail->SMTPDebug = 3; // Enable verbose debug output
  6.  
  7. $mail->isSMTP(); // Set mailer to use SMTP
  8. $mail->Host = 'auth.smtp.1and1.co.uk'; // Specify main and backup SMTP servers
  9. $mail->SMTPAuth = true; // Enable SMTP authentication
  10. $mail->Username = '##########'; // SMTP username
  11. $mail->Password = '##########'; // SMTP password
  12. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  13. $mail->Port = 587; // TCP port to connect to
  14.  
  15. $mail->setFrom('orders@reasonstobejolly.com', 'Orders at Reasons to be Jolly');
  16. $mail->AddAddress($email, $firstName." ".$lastName); // Add a recipient
  17. $mail->addReplyTo('enquiries@reasonstobejolly.com', 'Order Enquiry');
  18.  
  19. $mail->isHTML(true); // Set email format to HTML
  20. $mail->Subject = "Your Order Has Been Received";
  21. $mail->Body = "Dear ".$firstName." ".$lastName."<br/>"
  22. . "Your order has been received; it will be processed as soon as possible and should be with you in the timeframe specified in our shipping guidelines.<br/>
  23.  
  24. ";
  25. if (isset($randomPassword)) {
  26. $mail->Body .= "<p>Username: $email</p><p>Password: $randomPassword</p>";
  27. }
  28.  
  29.  
  30. $mail->Body .= "<p>Order Reference : $transactionId<br/>
  31. Order Date : ".date('d-m-Y H:i:s', strtotime($orderTime))."</p>
  32.  
  33. <p>BILL TO:<br/>
  34. $shipToName <br/>
  35. $shipToStreet<br/>
  36. $shipToCity<br/>
  37. $shipToState<br/>
  38. $shipToZip<br/>
  39. </p>
  40. <p>
  41. DELIVER TO:<br/>
  42. $shipToName <br/>
  43. $shipToStreet<br/>
  44. $shipToCity<br/>
  45. $shipToState<br/>
  46. $shipToZip<br/>
  47. </p>
  48.  
  49. <table>
  50. <tr><td>Qty</td><td>Description</td><td>Price</td></tr>";
  51. $orderOverviewID = getOrderOverviewIDByPayPalReference($transactionId);
  52.  
  53. $orderItemsArray = getItemsByOrderOverviewID($orderOverviewID);
  54. $postage = 0;
  55. foreach ($orderItemsArray as $id => $order) {
  56.  
  57. $productEmail = getProductByProductID($order->productID);
  58. $postageAmount = getPostageByPostageID($productEmail->postageID);
  59. $mail->Body .= "<tr><td>".$order->itemQuantity."</td>"
  60. . "<td>".$productEmail->productName."</td>"
  61. . "<td>&pound;". (getDimensionByID(getColourByID($order->colourID)->dimensionID)->dimensionPrice) * $order->itemQuantity."</td></tr>";
  62. if ($postageAmount->postagePrice > $postage) {
  63. $postage = $postageAmount->postagePrice;
  64. }
  65. }
  66. // these are from create invoice.
  67.  
  68. $vat = $amt * 0.2;
  69. $subtotal = $amt - $postage;
  70. // TODO VAT and postage need to be calculated in the Paypal bit.
  71. $mail->Body .= "<tr><td></td><td align='right'>Sub Total:</td> <td>&pound;$subtotal</td></tr>
  72. <tr><td></td><td align='right'>Standard Delivery:</td><td>&pound;$postage</td></tr>
  73. <tr><td></td><td align='right'>(Including VAT @ 20%):</td><td>&pound;$vat</td></tr>
  74. <tr><td></td><td align='right'>GRAND TOTAL:</td><td>&pound;$amt</td></tr>
  75. </table>
  76.  
  77.  
  78. If you have a query, or require further information, please contact Customer Service at: http://www.reasonstobejolly.com";
  79.  
  80. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  81. $mail->send();
  82. } catch (phpmailerException $e) {
  83. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  84. } catch (Exception $e) {
  85. echo $e->getMessage(); //Boring error messages from anything else!
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement