UserNameIsTaken Posted July 14, 2010 Share Posted July 14, 2010 Please help me this is driving me crazy <?php $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: WebForm <[email protected]>' . "\r\n"; $subject = 'Web Form Submission'; $to = '[email protected]'; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $email = $_POST['email']; $propdetails = $_POST['propdetails']; $message = " <html> <head> </head> <body> <table> <tr><th>Name</th><td>".$fname." ".$lname."</td></tr> <tr><th>Phone</th><td colspan=\"2\">".$phone."</td></tr> <tr><th>Email</th><td colspan=\"2\">".$email."</td></tr> <td colspan=\"2\">".$propdetails."</td></tr> </table> </body> </html> "; if (!mail($to, $subject, $message, $headers)) { $msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers; } else { $msg = "Thank you"; } echo $msg; ?> Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 Since you didn't bother to state which result you get, it's not directly possible to help. What do you see in front of you that leads you to believe that the code is not working? Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086046 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 I get the output of if (!mail($to, $subject, $message, $headers)) { $msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers; } Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086047 Share on other sites More sharing options...
xcoderx Posted July 14, 2010 Share Posted July 14, 2010 I get the output of if (!mail($to, $subject, $message, $headers)) { $msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers; } not the table right? Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086052 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 I get the output of if (!mail($to, $subject, $message, $headers)) { $msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers; } not the table right? I do see the table.. this is the exact html output Sending [email protected] - Web Form Submission - <html> <head> </head> <body> <table> <tr><th>Name</th><td>Bram Eastveld</td></tr> <tr><th>Phone</th><td colspan="2">416-488-2073</td></tr> <tr><th>Email</th><td colspan="2">[email protected]</td></tr> <td colspan="2">I want a LOFT</td></tr> </table> </body> </html> - MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: WebForm <[email protected]> Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086053 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 Add the following two lines of code after the line with your first opening <?php tag to see if there are any php detected errors as to why the mail() function call is failing - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086055 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 Add the following two lines of code after the line with your first opening <?php tag to see if there are any php detected errors as to why the mail() function call is failing - ini_set("display_errors", "1"); error_reporting(E_ALL); I added the lines you suggested so my code now reads <?php ini_set("display_errors", "1"); error_reporting(E_ALL); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: WebForm <[email protected]>' . "\r\n"; $subject = 'Web Form Submission'; $to = '[email protected]'; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $email = $_POST['email']; $propdetails = $_POST['propdetails']; $message = " <html> <head> </head> <body> <table> <tr><th>Name</th><td>".$fname." ".$lname."</td></tr> <tr><th>Phone</th><td colspan=\"2\">".$phone."</td></tr> <tr><th>Email</th><td colspan=\"2\">".$email."</td></tr> <td colspan=\"2\">".$propdetails."</td></tr> </table> </body> </html> "; if (!mail($to, $subject, $message, $headers)) { $msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers; } else { $msg = "Thank you"; } echo $msg; ?> The output is the same though, no additional msgs Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086058 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 That either means - 1) The ini_set() function is disabled on your server (you cannot turn on display_errors to find what error is occurring), 2) the mail() function is disabled on your server, or 3) Your mail server has been configured to silently accept emails that it has no intention of sending so as to not provide hackers with any server information in the form of error messages. In any of those cases, you would need to contact your web host to find out the requirements for sending email. Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086062 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 That either means - 1) The ini_set() function is disabled on your server (you cannot turn on display_errors to find what error is occurring), 2) the mail() function is disabled on your server, or 3) Your mail server has been configured to silently accept emails that it has no intention of sending so as to not provide hackers with any server information in the form of error messages. In any of those cases, you would need to contact your web host to find out the requirements for sending email. I spoke with them today and they assured me that mail() is working... I'll call them, thank you Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086068 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 Are both the From: and To: email address you are using, valid mail boxes (they exist) and are hosted at the mail server? Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086070 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 Are both the From: and To: email address you are using, valid mail boxes (they exist) and are hosted at the mail server? Yes Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086071 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 Then it is likely that only your web host will be able to tell you why the mail() function call is returning a false value. Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086075 Share on other sites More sharing options...
UserNameIsTaken Posted July 14, 2010 Author Share Posted July 14, 2010 Then it is likely that only your web host will be able to tell you why the mail() function call is returning a false value. I'm on the phone with them now, they said that the from address is not being used... the server is complaining that one isnt being provided or something... been on the phone for 15mins... hope they can tell me what's up Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086077 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 Some mail servers don't like and won't parse the name <email> format. Just try - 'From: [email protected]' as the From: address. Quote Link to comment https://forums.phpfreaks.com/topic/207754-why-will-mail-not-send/#findComment-1086090 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.