kat35601 Posted November 17, 2015 Share Posted November 17, 2015 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! "); } ?> Quote Link to comment Share on other sites More sharing options...
budimir Posted November 17, 2015 Share Posted November 17, 2015 Three questions: 1) Is mail really sent to the person? 2) What do you get when you echo $text variable? 3) Did you jsut copy/paste that script or you know what you're variables are ($host variable?)? Quote Link to comment Share on other sites More sharing options...
kat35601 Posted November 17, 2015 Author Share Posted November 17, 2015 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 Quote Link to comment Share on other sites More sharing options...
budimir Posted November 18, 2015 Share Posted November 18, 2015 Can you show you're code in include("kf_open_order_status.php");? Quote Link to comment Share on other sites More sharing options...
kat35601 Posted November 18, 2015 Author Share Posted November 18, 2015 (edited) 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 November 18, 2015 by kat35601 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.