wright67uk Posted May 5, 2013 Share Posted May 5, 2013 What is the best way to test an email has been sent when using php mail? I need to add a mysql update, but I need to test that the email has definitely been sent. Is it good enough to put the below code into an IF block? $to = $user_email; $subject = 'A reminder from TNT'; $message = $info_msg; $headers = 'From: reminder@reminder.com' . "\r\n" . 'Reply-To: reminder@reminder.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); // if mail sent then do this... Quote Link to comment https://forums.phpfreaks.com/topic/277679-how-can-i-test-php-mail/ Share on other sites More sharing options...
Jessica Posted May 5, 2013 Share Posted May 5, 2013 mail() returns a boolean. However, it does only ensure it was sent, not recieved. Quote Link to comment https://forums.phpfreaks.com/topic/277679-how-can-i-test-php-mail/#findComment-1428481 Share on other sites More sharing options...
wright67uk Posted May 5, 2013 Author Share Posted May 5, 2013 Thankyou so... if (mail($to, $subject, $message, $headers)) {do this}; and how in-depth would it be to test for returned messages ie. undeliverable? Quote Link to comment https://forums.phpfreaks.com/topic/277679-how-can-i-test-php-mail/#findComment-1428486 Share on other sites More sharing options...
Jessica Posted May 5, 2013 Share Posted May 5, 2013 Very. Quote Link to comment https://forums.phpfreaks.com/topic/277679-how-can-i-test-php-mail/#findComment-1428487 Share on other sites More sharing options...
wright67uk Posted May 5, 2013 Author Share Posted May 5, 2013 Ok lol thanks Quote Link to comment https://forums.phpfreaks.com/topic/277679-how-can-i-test-php-mail/#findComment-1428489 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.