levi2613 Posted January 25, 2009 Share Posted January 25, 2009 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; } Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/ Share on other sites More sharing options...
DeanWhitehouse Posted January 25, 2009 Share Posted January 25, 2009 It shouldn't do that, but just in case it is caused by what i think try putting an @ symbol in front of the mail function Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-745938 Share on other sites More sharing options...
corbin Posted January 25, 2009 Share Posted January 25, 2009 Are you sure the script isn't just timing out? PHP's mail() function is notoriously slow since it opens a new connection each time. Blade, how would @ help? mail() doesn't even throw a fatal error. Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-745946 Share on other sites More sharing options...
DeanWhitehouse Posted January 25, 2009 Share Posted January 25, 2009 Yeah i thought it didn't, that's why his question didn't make sense, therefore i was asking him to put that in to see if it is the problem. Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-745953 Share on other sites More sharing options...
chronister Posted January 25, 2009 Share Posted January 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-745968 Share on other sites More sharing options...
levi2613 Posted February 6, 2009 Author Share Posted February 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-756337 Share on other sites More sharing options...
levi2613 Posted February 6, 2009 Author Share Posted February 6, 2009 I meant "SMS" of course... Quote Link to comment https://forums.phpfreaks.com/topic/142366-solved-mail-function-fails-after-invalid-address/#findComment-756351 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.