SonyaS Posted November 15, 2010 Share Posted November 15, 2010 Hi, I'm pretty new to PHP and I am working on a form that sends and email. I want to display a message if the mail can't be sent (i.e. if mail() returns false) and a different message if mail() returns true, except it is returning false even though the emails are sending. Basically I have used: $to = '[email protected]'; $subject = "Subject Line Goes here"; $headers = "From: $email"; $message = 'My message'; $mailSent = mail($to, $subject, $message, $headers); In testing it I have used the following to determine what is going on: if (isset($mailSent)) { echo '$mailSent ='.$mailSent; } - echo's nothing if ($mailSent == FALSE) { echo '$mailSent = FALSE'; } - echo's '$mailSent = FALSE' if ($mailSent == TRUE) { echo '$mailSent = TRUE'; } - echo's nothing if (is_null($mailSent)) { echo '$mailSent = NULL'; } - echo's '$mailSent = NULL' echo '$mailSent ='.$mailSent; - echo's '$mailSent =' Any help would be greatly appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/218699-mail-returns-false-but-email-is-sent/ Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 if( $mailSent ) { echo 'Mail Sent.'; } else { echo 'Mail Not Sent.'; } // To see what is actually contained by $mailSent var_dump($mailSent); Link to comment https://forums.phpfreaks.com/topic/218699-mail-returns-false-but-email-is-sent/#findComment-1134453 Share on other sites More sharing options...
SonyaS Posted November 15, 2010 Author Share Posted November 15, 2010 Hi Pikachu2000, Thanks for your help. I should have said that previously I had the 'if ($mailSent) { echo 'Mail Sent'; } else { echo 'Mail not sent'; }' statement and this was returning back with the else response when the mail was actually sent. The var_dum($mailSent) returns NULL. Link to comment https://forums.phpfreaks.com/topic/218699-mail-returns-false-but-email-is-sent/#findComment-1134704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.