Jump to content

Syntax help sending results of a query in and email.


kat35601

Recommended Posts

I want to send an email that includes the results from another page. But it does not work for me.  The hello works but the include does not go with the email but it does display on the page that tells me the email was sent. I may also have some code not needed to send the email but this is my first time  to use pear mail so I went with there example.

<?php
 require_once "Mail.php";
 require_once "Mail/mime.php";
 


 $from = "removed.com";
 $to = "removed@txt.att.net";
 $subject = "Status\r\n\r\n";
#$text="hello";
 $text = include("kf_open_order_status.php");
 $html = "";
 $crlf = "\n";
 $mime = new Mail_mime($crlf); 
 $mime->setTXTBody($text); 
 $mime->setHTMLBody($html);
 $host = "smtp.gmail.com";
 $username = "removed.com";
 $password = "removed";
 $headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
 $smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
 $body = $mime->get();
 $headers = $mime->headers($headers); 
 $mail = $smtp->send($to, $headers, $body);
 if (PEAR::isError($mail)) {
  echo("
" . $mail->getMessage() . "
");
} else {
  echo("

Message successfully sent!
");
}
?>
Link to comment
Share on other sites

Yes the mail is sent to the person

I get a "1" both in the email and the echo of $text

 

But on the page I get the full echo of the included page. The output on the page Below( the 1 with Message successfully sent! is what is in the txt or email just a 1)

 

 

Message successfully sent! 1

Status   Orders   Total Customer ◃ 3 ▹ 20 Minimal ◃ 11 ▹ 4 Product ◃ 504 ▹ 424 Released ◃ 282 ▹ 511
Link to comment
Share on other sites

Sure this is the code for  information I would like to send. I wanted to use an include because I thought it would be easier to change in the future.


<!DOCTYPE html>
<html lang="en">
<head>
  <title>DashBoard</title>
 
</head>
<body>

<?php
	
$grandTotal = 0;
$connect =odbc_connect("removed");
if(!$connect) {
	exit("Connection Failed: " . $connect);
}

$sql="select
case 
when rtrim(so.uompfurnhold) in ('0','1','')  then 'Released'
when rtrim(so.uompfurnhold) ='2' then 'Product'
when rtrim(so.uompfurnhold) ='3' then 'Minimal'
when rtrim(so.uompfurnhold) ='4' then 'Customer'
 else 'GO' end as OrdStatus,
count(SO.ompSalesOrderID) as orders,round(sum(SO.ompOrderSubTotalBase),2) as total 
FROM   m1_kf.dbo.SalesOrders SO
Where    so.ompClosed !=-1
Group by case 
when rtrim(so.uompfurnhold) in ('0','1','')  then 'Released'
when rtrim(so.uompfurnhold) ='2' then 'Product'
when rtrim(so.uompfurnhold) ='3' then 'Minimal'
when rtrim(so.uompfurnhold) ='4' then 'Customer'
 else 'GO' end 	";

$result =odbc_exec($connect,$sql);
if(!$result){
exit("Error in SQL");
}
#echo "SalesPerson Total". date("m-d-Y") ;
echo "<table><tr>";
echo "<th>Status</th>";
 echo "<th>  </th>";
echo "<th>Orders</th>";
 echo "<th>  </th>";
echo "<th>Total</th></tr>";

while (odbc_fetch_row($result)) {
	 

  $OrdStatus=odbc_result($result,"OrdStatus");
  $orders=odbc_result($result,"orders");
  $total=odbc_result($result,"total");


$num = number_format($total, 2, '.', ',');
 $grandTotal += $total;
 
  echo "<tr><td>$OrdStatus</td>";
  echo "<td> ◃ </td>";
  echo "<td align='center' >$orders</td>";
   echo "<td> ▹ </td>";
  echo "<td>$num</td>";
  # echo "<td align='right'>$num</td></tr>";
   
}
#$num2 = number_format( $grandTotal, 2);
#echo "Grand Total: $num2";

odbc_close($connect);
?>

</body>
</html>
Edited by kat35601
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.