PHP: view unsuccessful emails

I am trying to figure out how to display a list of unsuccessful sent emails and a way to check it. I can display a list of sent emails, but I'm not sure how to get a list of emails that were sent unsuccessfully.

This is what I use to extract from mysqldb:

            //get the email address list
            $query = "SELECT email FROM users 
                    WHERE id IN (SELECT participant_id FROM roster AS ur WHERE ur.roster_id=".$roster['roster_id'].")";
            $result = mysql_query($query);
            $emailstring2 = "";
            $email2 = $result;
            while ($row = mysql_fetch_object($email2)){
            $emailstring2 .= $row->email. "\n ";
}

      

In the posts section, I get it via:

   $message .="Successful emails: \n".$emailstring2." \r\n";

      

How can I achieve this?

+3


source to share


2 answers


One keyword will get you the ones that aren't sent: NOT



WHERE id NOT IN 

      

+6


source


You cannot do this with PHP in an easy way.

Think of it like a letter going through the postal service. All you can do is hand the letter over to the postman and hope that he reaches his destination. The postman will not come back and tell you if the delivery was successful or if the email was actually read by the recipient. The PHP mail () function (and its derivatives) returns TRUE to indicate that a message was accepted for delivery attempts, not that it was successfully delivered. (Delivery may not occur for hours or days.)



As a result, the best thing you can do is an approximate delivery notification. There are several ways to do this:

  • Use a tracking pixel in an email that is pinged when a user opens a message. However, given that most email clients nowadays do not show images by default, I think this method is rather unreliable.
  • Send each message with a unique recipient address. If the message cannot be delivered, it will fall back to the user's address - and this return message can be used to indicate that the recipient's email address is not good. This is probably the most accurate method, but not easy to set up.
  • Use return receipts. Like tracking pixels, I think most email clients never send them by default, so this is probably unreliable as well.
  • Use delivery status notification. This would require using a server that supports it and sends it to a server that supports it.
  • Send your emails through a service that will perform a similar search. (For example MailChimp or regular contact)
0


source







All Articles