Xurion Posted January 28, 2007 Share Posted January 28, 2007 I have a line of code in my php page that send an email with the following code:mail('me@mydomain.com','my subject','email text',$mailheaders);When the page loads, it will display the confirmation message saying thank you etc. But if for whatever reason the smtp of the server is down, if there any php that can detect this?Thx in adv.Xur~ Quote Link to comment Share on other sites More sharing options...
alpine Posted January 28, 2007 Share Posted January 28, 2007 [code]<?php$status = mail('me@mydomain.com','my subject','email text',$mailheaders);if($status == 1){ // mail() returned true}else{ // failed}?>[/code]That's about the closest you get to a success-machine Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 28, 2007 Share Posted January 28, 2007 the mail() function returns true if successfull or false if failed. so this would work:[code=php:0]if(mail('me@mydomain.com','my subject','email text',$mailheaders)){echo "Message was sent!";}else{echo "Problem sending message!";}[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 28, 2007 Share Posted January 28, 2007 It can only tell if the mail was accepted for delivery. There are other factors that can stop mail from being sent or recieved, which PHP cannot tell. Quote Link to comment 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.