Jump to content

[SOLVED] mail function fails after invalid address


levi2613

Recommended Posts

I have a function that sends a short email to people who have signed up for the service.  Unfortunately, some people do not sign up with valid email addresses, and these seem to cause my loop to fail without mailing those who have valid addresses.  Any ideas?

 

foreach($address_arr as $address) {
         $success = mail($address,'Open Shift',$body,'From: DCEMS');
         if ($success)
            $success_arr[] = "Successful notification: " . $address;
         else
            $_ERROR[] = "Failed notification: " . $address;
      }

You can use checkdnsrr for a valid MX record. I use this to validate email addresses. This way at least a person will HAVE to put in a valid domain, even if it is not actually their email address.

<?php

if(checkdnsrr('yahoo.com' )) {
  echo 'MX record was found';
}
?>

 

Nate

  • 2 weeks later...

Chronister: thanks much.  I used this, and it increased the number of emails sent, though I'm still not quite at 100%.  After talking with US Cellular (most of the addresses failing were their SMP addresses), I think it's an issue of them accepting the messages. <shrug>

 

Thanks again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.