Link to home
Start Free TrialLog in
Avatar of Michelle Jackson
Michelle Jackson

asked on

PHP Mail says it was sent but never actually sends

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.
$con = mysqli_connect ('','loginxxx','passwordxxx');
if (!$con)
  die('Could not connect:' . mysqli_error());
  $result = mysqli_query($con,"SELECT * FROM logins WHERE logintime >=(CURRENT_DATE - INTERVAL 7 DAY)");
  $from = "";
  $host = "";
  $username = "xxxx";
  $password = "xxx";
  $port = "587";
  $to = "";
  $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>";
  $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";

  echo "Mail sent to ";

Open in new window

Avatar of David Favor
David Favor
Flag of United States of America image

With email...

Sending != Delivering

2x different beasts.

Sending is super easy. covers the absolute minimal checklist to begin the delivery process.

Then you may require warming up IPs + other related tasks.

If the above checklist is new to you, then subscribe to a Mail Relay service like to ensure your messages actually deliver.

Note: You can check your MTA logs to determine exact reason for failure.

Where MTA will be something like Sendmail, Postfix, EXIM, etc...
Avatar of Michelle Jackson
Michelle Jackson


Thanks David Foster, I will take a look at it now.
You need to treat this type of authentication similar to a multi function device 

Based on this you need to send using tls and authenticated

Log into your admin portal and see if you can find any issues logged.
Avatar of Michelle Jackson
Michelle Jackson

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial