Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require '../../../PHPMailer-master/PHPMailerAutoload.php';
- $mail = new PHPMailer(true);
- try {
- $mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'auth.smtp.1and1.co.uk'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = '##########'; // SMTP username
- $mail->Password = '##########'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->setFrom('orders@reasonstobejolly.com', 'Orders at Reasons to be Jolly');
- $mail->AddAddress($email, $firstName." ".$lastName); // Add a recipient
- $mail->addReplyTo('enquiries@reasonstobejolly.com', 'Order Enquiry');
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = "Your Order Has Been Received";
- $mail->Body = "Dear ".$firstName." ".$lastName."<br/>"
- . "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/>
- ";
- if (isset($randomPassword)) {
- $mail->Body .= "<p>Username: $email</p><p>Password: $randomPassword</p>";
- }
- $mail->Body .= "<p>Order Reference : $transactionId<br/>
- Order Date : ".date('d-m-Y H:i:s', strtotime($orderTime))."</p>
- <p>BILL TO:<br/>
- $shipToName <br/>
- $shipToStreet<br/>
- $shipToCity<br/>
- $shipToState<br/>
- $shipToZip<br/>
- </p>
- <p>
- DELIVER TO:<br/>
- $shipToName <br/>
- $shipToStreet<br/>
- $shipToCity<br/>
- $shipToState<br/>
- $shipToZip<br/>
- </p>
- <table>
- <tr><td>Qty</td><td>Description</td><td>Price</td></tr>";
- $orderOverviewID = getOrderOverviewIDByPayPalReference($transactionId);
- $orderItemsArray = getItemsByOrderOverviewID($orderOverviewID);
- $postage = 0;
- foreach ($orderItemsArray as $id => $order) {
- $productEmail = getProductByProductID($order->productID);
- $postageAmount = getPostageByPostageID($productEmail->postageID);
- $mail->Body .= "<tr><td>".$order->itemQuantity."</td>"
- . "<td>".$productEmail->productName."</td>"
- . "<td>£". (getDimensionByID(getColourByID($order->colourID)->dimensionID)->dimensionPrice) * $order->itemQuantity."</td></tr>";
- if ($postageAmount->postagePrice > $postage) {
- $postage = $postageAmount->postagePrice;
- }
- }
- // these are from create invoice.
- $vat = $amt * 0.2;
- $subtotal = $amt - $postage;
- // TODO VAT and postage need to be calculated in the Paypal bit.
- $mail->Body .= "<tr><td></td><td align='right'>Sub Total:</td> <td>£$subtotal</td></tr>
- <tr><td></td><td align='right'>Standard Delivery:</td><td>£$postage</td></tr>
- <tr><td></td><td align='right'>(Including VAT @ 20%):</td><td>£$vat</td></tr>
- <tr><td></td><td align='right'>GRAND TOTAL:</td><td>£$amt</td></tr>
- </table>
- If you have a query, or require further information, please contact Customer Service at: http://www.reasonstobejolly.com";
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- } catch (phpmailerException $e) {
- echo $e->errorMessage(); //Pretty error messages from PHPMailer
- } catch (Exception $e) {
- echo $e->getMessage(); //Boring error messages from anything else!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement