DeanWhitehouse Posted May 7, 2008 Share Posted May 7, 2008 just a quick quest, how do i check if an email is sent? this is my email code $to = $user_email; $subject = 'Welcome,'$user_name; $message = "Hello,$user_name<br> welcome to the Random Game Design Template System<br> Congratulations on succesfully creating your site. This email can be fully customised in the admin centre $homepage."; $headers = 'From: RGD TS' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); can i just add if(mail() { //my code } else { } Link to comment https://forums.phpfreaks.com/topic/104596-check-if-mail-is-sent/ Share on other sites More sharing options...
paul2463 Posted May 7, 2008 Share Posted May 7, 2008 you just do if(mail($to, $subject, $message, $headers)) { //do something if true } else { //do something else } mail() returns a bool value, TRUE if mail is sent successfully and FALSE if there was an error Link to comment https://forums.phpfreaks.com/topic/104596-check-if-mail-is-sent/#findComment-535373 Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2008 Share Posted May 7, 2008 A TRUE status returned by the mail() function only means it was able to talk to the mail server and the mail was accepted for delivery. After an email has been accepted for delivery, a lot of things could happen that could result in the mail not being sent. Link to comment https://forums.phpfreaks.com/topic/104596-check-if-mail-is-sent/#findComment-535433 Share on other sites More sharing options...
paul2463 Posted May 8, 2008 Share Posted May 8, 2008 yes indeed, however, IMHO, after the mail server has accepted the mail for delivery then the other problems are outside the coders control. so a quick and simple check to see whether the mail has been handed over successfully to the mail server is to check for a TRUE return statement from the function. Link to comment https://forums.phpfreaks.com/topic/104596-check-if-mail-is-sent/#findComment-535911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.