Initially, the phpmailer was not sending mail from this page of mine, but I managed to fix it. This time, the message sends to the email variable and all other contents except variables already declared in the page aren't showing.
The source code to the page is the following;
<?php
require_once("connection.php");
?>
<?php
$date_order = gmdate('M d, Y');
$time_order = gmdate('H:i:s');
$cust_ID = $_SESSION['cust_ID'];
$order_ref = $_SESSION['order_ref'];
$query1 = mysql_query("SELECT * FROM order_receipts WHERE order_ref='$order_ref'");
$num1 = mysql_num_rows($query1);
if($num1<1)
{
$query = mysql_query("INSERT INTO order_receipts (order_ref,cust_id,date_order,time_order) VALUES ('$order_ref','$cust_ID','$date_order','$time_order')");
}
$query2 = mysql_query("SELECT * FROM personal_details WHERE id='$cust_ID'");
while($rows = mysql_fetch_assoc($query2))
{
$title = $rows['title'];
$first_name = $rows['first_name'];
$last_name = $rows['last_name'];
$middle_name = $rows['middle_name'];
$email_address = $rows['email_address'];
$fullname = $title." ".$first_name." ".$middle_name." ".$last_name;
}
$query3 = mysql_query("SELECT * FROM order_details WHERE order_ref='$order_ref' AND customer_id = $cust_ID");
while($row2 = mysql_fetch_assoc($query3))
{
$title = $row2['title'];
$product_sample = $row2['product_sample'];
$dress_type = $row2['dress_type'];
$name_of_dress = $row2['name_of_dress'];
$sewing_end_date = $row2['sewing_end_date'];
$service_charge = $row2['service_charge'];
$amount_paid = $row2['amount_paid'];
$prod_desc = $row2['prod_desc'];
$date_order = $row2['date_order'];
$sewing_start_date = $row2['sewing_start_date'];
$sumtotal += $rows2['service_charge'];
$sumadvance += $rows2['amount_paid'];
}
require("/home/sewsoftc/public_html/PHPMailer_5.2.0/class.smtp.php");
require("/home/sewsoftc/public_html/PHPMailer_5.2.0/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "localhost";
$mail-> Port = 587;
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = 'tls';
$mail->Username = "sender@mail.com"; // SMTP username
$mail->Password = "sender_password"; // SMTP password
$mail->From = "noreply@mail.com";
$mail->FromName = "Unania Ltd.";
$mail->AddAddress("$email_address", "$fullname");
$mail->AddReplyTo("admin@mail.com", "Information");
$mail->AddEmbeddedImage ("images/una_mail.png","unanialogo","images/una_mail.png");
$mail->AddEmbeddedImage("$product_sample","ordersample","$product_sample");
$mail->WordWrap = 50;
$mail->IsHTML(true);
//$message = file_get_contents("msg.php");
$mail->Subject = "Order Notification From Unania Couture";
$mail->Body = "<table>
<tr style='background:#D71576; height:140px; width:100%;'>
<td style='padding:22px 0; text-align:center;'><img src='cid:unanialogo' /></td>
</tr>
<tr style='color:#056FFF; font-size:18px; font-weight:bold;'>
<td><br />Dear <?php echo ''.$fullname; ?>,<br /><br /><span style='color:#636D76; font-size:16px; font-weight:normal;'>Thank you for ordering our tailoring service. The order details of your dress are enclosed in the receipt below for your record.</span><br /></td></tr>
<tr>
<td>
<table style='width:90%; margin:0 auto; font-family:tahoma; font-size:12px;' align='center'>
<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Name</td>
<td colspan='3' style='width:49%; background: #3B88F3;'><?php echo ''.$title.' '.$first_name.' '.$middle_name.' '.$last_name; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Invoice No</td>
<td style='width:15%; background: #3B88F3;'><?php echo ''.$order_ref; ?></td>
</tr>
<?php
while($row2 = mysql_fetch_assoc($query3))
{?>
<tr style='background:#fff; color:#000; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Style</td>
<td style='width:19%; background:#E5DDDD;'><?php echo ''.$dress_type.' - '.$name_of_dress; ?></td>
<td style='width:16%; font-size:113%; font-weight:bold; font-family:calibri;'>Projected Date of Completion</td>
<td style='width:12%; background:#E5DDDD;'><?php echo ''.$sewing_end_date; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Service Charge</td>
<td style='width:15%; background:#E5DDDD;'><?php echo ''.$service_charge; ?></td>
</tr>
<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Description</td>
<td colspan='3' style='width:49%; background: #3B88F3;'><?php echo ''.$prod_desc; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Dress Sample</td>
<td style='width:15%; background: #3B88F3;'><img src='cid:ordersample' width='50' height='50'/></td>
</tr>
<?php } ?>
<tr style='background:#fff; color:#000; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Total Charge</td>
<td colspan='3' style='width:49%; background: #E5DDDD;'><?php echo ''.$sumtotal; ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Advance Payment</td>
<td style='width:15%; background:#E5DDDD;'><?php echo ''.$sumadvance; ?></td>
</tr>
<tr style='background:#056FFF; color:#fff; font-size:16px;'>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Balance Remaining</td>
<td colspan='3' style='width:49%; background: #E5DDDD;'>₦<?php echo ''.$balance_remaining = -($sumtotal - $sumadvance); ?></td>
<td style='width:19%; font-size:113%; font-weight:bold; font-family:calibri;'>Order Date</td>
<td style='width:15%; background:#3B88F3;'><?php echo ''.$order_date; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><br /><span style='color:#636D76; font-size:16px; font-weight:normal;'>
Please note that all outstanding payments will be duly collected when the dress is completed and ready to be collected. We hope to bring you an unequaled satisfactory service. We will keep in touch with you to let you know when your dress is completed.</span>
<br /><br /><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>This email you received is an automated message sent to you by Unania Couture in response of any activity that concerns you within the company.</span><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>Do not reply back to this mail, as our administration staff will not be able to give any feedback following your reply, but contact us on admin@sew-soft.com</span><br /><br /><br /><span style='color:#637894; font-size:15px; font-weight:normal;'>To unsubscribe from automatic email notification, please click this link <a href='#'>Unsubscribe me</a></span>
</td></tr>
</table>";
if($mail->Send()) {
echo "Message sent!";
} else {
echo "Mailer Error: " . $mail->ErrorInfo;
}
//echo $_SESSION['order_ref'];
//echo "<br />".$fullname;
//echo("<script>location.href = 'receipt2.php?order_ref=$order_ref&cust_ID=$cust_ID';</script>");
?>
I also echoed out the variables to see if it were set, and it was showing fine.