troubleshooting Question

PHP Mail says it was sent but never actually sends

Avatar of Michelle Jackson
Michelle Jackson asked on
PHP
4 Comments1 Solution26 ViewsLast Modified:
I am trying to build a PHP app to send query results to multiple users. When I run the program it states that the message was sent but it is not actually sent, I never receive it. I must be missing something here. Could someone please take a look and point me in the right direction?  I am using AMPPS to test this. Thanks.
<?php
//include("DBConstants.php");
$con = mysqli_connect ('xxx.xxx.xxx.xxx','loginxxx','passwordxxx');
if (!$con)
  {
  die('Could not connect:' . mysqli_error());
  }
  mysqli_select_db($con,"xxx");
  $result = mysqli_query($con,"SELECT * FROM logins WHERE logintime >=(CURRENT_DATE - INTERVAL 7 DAY)");
  $from = "xxx@xx.com";
  $host = "smtp.office365.com";
  $username = "xxxx";
  $password = "xxx";
  $port = "587";
  $to = "myemail@myemail.com";
  $subject = "Logins";
  $body = "<table border='1'>";
  $body .= "<tr>";
  $body .= "<th>LOGIN:</th>";
  $body .= "<th>TIME:</th>";
  
  $body .= "</tr>";
 while($row = mysqli_fetch_array($result)){
  $body .="<tr>";
  $body .="<td>" . $row['userid'] . "</td>";
  $body .="<td>" . $row['logintime'] . "</td>";
  
  $body .="</tr>";
  }
  $body .="</table>";
  mysqli_close($con);
  ;
  
  $headers = "Return-Path: $from\n";
  $headers .= "X-Sender: $from\n";
  $headers .= "From: $from\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";


  mail($to,$subject,$body,$headers);
  echo "Mail sent to myemail@myemail.com ";
?>

Open in new window

ASKER CERTIFIED SOLUTION
Michelle Jackson

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 4 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 4 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004