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: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); // if mail sent then do this... 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. 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? 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. 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 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
Archived
This topic is now archived and is closed to further replies.