tinwakr Posted February 4, 2012 Share Posted February 4, 2012 Hi Everyone, Please have a look at the code below the first set is from my contact form and the second is the function, it is a function that is passed a form variable in the form of an array and is also passed a form title variable. Everything worked fine this morning but when I checked the functionality of it a few hours ago the mail function wasn't sending, although the logic was working. I checked my spam filter and the emails weren't held up there. require('../php_classes/TrueViewI.php'); include('../php_functions/functions.php'); if(isset($_POST['submit'])) { $error_message = processFormData($_POST, 'Home Inspections'); if($error_message == 'Thank you, someone will contact you shortly.') { session_unset(); } } //future $keywords = ''; //future $meta_tags = ''; //future $left_column = ''; $middle_column = '<img class="page_heading" src="../images/contactus.png" alt="True View Service Home Inspections Contact Us" /> <form method="post" action=""> <fieldset id="contactform"> <!-- <legend>Home Inspections Contact Form</legend> --> <h4>Home Inspections Contact Form</h4> <span class="errors">'.(!empty($error_message) ? $error_message : '').'</span> <div class="row_div"> <div class="label_div"> <label>First Name:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="First Name" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['First_Name']) ? $_SESSION['First_Name'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Last Name:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="Last Name" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['Last_Name']) ? $_SESSION['Last_Name'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Phone Number:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="Phone Number" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['Phone_Number']) ? $_SESSION['Phone_Number'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Email Address:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="Email Address" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['Email_Address']) ? $_SESSION['Email_Address'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Renovation Address:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="Renovation Address" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['Renovation_Address']) ? $_SESSION['Renovation_Address'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Age of Home:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <select name="Age Of Home" class="input"> <option value="">--Choose One--</option> <option value="0-10"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '0-10')) ? ' selected="selected" ' : ''). '>0 to 10 years old</option> <option value="11-20"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '11-20')) ? ' selected="selected" ' : ''). '>11 to 20 years old</option> <option value="21-30"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '21-30')) ? ' selected="selected" ' : ''). '>21 to 30 years old</option> <option value="31-40"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '31-40')) ? ' selected="selected" ' : ''). '>31 to 40 years old</option> <option value="41-50"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '41-50')) ? ' selected="selected" ' : ''). '>41 to 50 years old</option> <option value="50+"'. ((!empty($_SESSION['Age_Of_Home']) && ($_SESSION['Age_Of_Home'] == '50+')) ? ' selected="selected" ' : ''). '>More than 50 years old</option> </select> </div> </div> <div class="row_div"> <div class="label_div"> <label>Square Footage of Home:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <select name="Square Footage Of Home" class="input"> <option value="">--Choose One--</option> <option value="1000-1500"'. ((!empty($_SESSION['Square_Footage_Of_Home']) && ($_SESSION['Square_Footage_Of_Home'] == '1000-1500')) ? ' selected="selected" ' : ''). '>1000 to 1500 square feet</option> <option value="1501-2000"'. ((!empty($_SESSION['Square_Footage_Of_Home']) && ($_SESSION['Square_Footage_Of_Home'] == '1501-2000')) ? ' selected="selected" ' : ''). '>1501 to 2000 square feet</option> <option value="2001-2500"'. ((!empty($_SESSION['Square_Footage_Of_Home']) && ($_SESSION['Square_Footage_Of_Home'] == '2001-2500')) ? ' selected="selected" ' : ''). '>2001 to 2500 square feet</option> <option value="2501-3000"'. ((!empty($_SESSION['Square_Footage_Of_Home']) && ($_SESSION['Square_Footage_Of_Home'] == '2501-3000')) ? ' selected="selected" ' : ''). '>2501 to 3000 square feet</option> <option value="3000+"'. ((!empty($_SESSION['Square_Footage_Of_Home']) && ($_SESSION['Square_Footage_Of_Home'] == '3000+')) ? ' selected="selected" ' : ''). '>More than 3000 square feet</option> </select> </div> </div> <div class="row_div"> <div class="label_div"> <label>Are you buying or selling?:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <select name="Buying Or Selling" class="input"> <option value="">--Choose One--</option> <option value="Buying"'.((!empty($_SESSION['Buying_Or_Selling']) && ($_SESSION['Buying_Or_Selling'] == 'Buying')) ? ' selected="selected" ' : '').'>Buying</option> <option value="Selling"'.((!empty($_SESSION['Buying_Or_Selling']) && ($_SESSION['Buying_Or_Selling'] == 'Selling')) ? ' selected="selected" ' : '').'>Selling</option> </select> </div> </div> <div class="row_div"> <div class="label_div"> <label>Preferred Date and Time for Inspection:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <input name="Preferred Date and Time for Inspection" type="text" maxlength="50" size="50" value="'. (!empty($_SESSION['Preferred_Date_and_Time_for_Inspection']) ? $_SESSION['Preferred_Date_and_Time_for_Inspection'] : '').'" /> </div> </div> <div class="row_div"> <div class="label_div"> <label>Comments or Questions:</label> <!-- <span class="required">* </span> --> </div> <div class="input_div"> <textarea name="Comments or Questions" type="text" rows="10">'. (!empty($_SESSION['Comments_or_Questions']) ? $_SESSION['Comments_or_Questions'] : '').'</textarea> </div> </div> <div class="row_div"> <input id="button" name="submit" type="submit" value="Send Message" /> </div> </fieldset> </form>'; $contact = new TrueViewI('True View Services Inspections - Contact Us', '../css/styles.css', NULL, NULL, 7, 1, 1); $contact->setContent('middle_col_content', $middle_column); $contact->display_page(); function processFormData($array, $form) { $errors = NULL; $message = NULL; foreach($array as $key => $value) { //if any of the form values are empty catch them and add to error array if(empty($value) && $key != 'submit') { //build error list $errors .= '"' . str_replace('_', ' ', $key) . '" is a required field!<br />'; } else if(!empty($value) && $key != 'submit') { //capture values and insert them into a session variable $_SESSION[$key] = $value; } } if(empty($errors)) { mail('tinwakr@bell.net', $form, str_replace('_', ' ', $message)); return 'Thank you, someone will contact you shortly.'; } else { return $errors; } } Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/ Share on other sites More sharing options...
gizmola Posted February 4, 2012 Share Posted February 4, 2012 I'm not sure what type of answer you expect. The reasonable question to ask yourself is -- what if anything changed? If the code did not change, and you've tested the form, then it is reasonable to assume that the problem is in your MTA (mailserver). Since you provided no information about the server environment, there's not much more anyone could tell you right now. the mail() call simply dumps the emails to the MTA, and the MTA should deliver them. Furthermore, if this is a local MTA that hasn't been properly configured and passes the types of checks that mail servers require these days (SPF record, DNS entries, reverse DNS resolution) then it's possible that the "bell.com" server will reject the emails outright, rather than putting them in a spam folder. You need to check what is happening with the MTA, and see if messages are being queued or delivered. Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314575 Share on other sites More sharing options...
tinwakr Posted February 4, 2012 Author Share Posted February 4, 2012 Thanks for the reply. I put at the top of the webpage in question the following: <?php mail('myemail@address.com', 'email subject', 'email message'); ?> When the page loads it should send the email, it doesn't. any other suggestions? Thanks, Chuck Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314578 Share on other sites More sharing options...
gizmola Posted February 4, 2012 Share Posted February 4, 2012 Again, I ask you -- did you check your mta? What is your mta? What is your operating system? What configuration settings for mail is in the php.ini? Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314585 Share on other sites More sharing options...
tinwakr Posted February 5, 2012 Author Share Posted February 5, 2012 Hi Everyone, I found out it seems Godaddy is trying to force their customers to use their web form mailer scripts which collect messages and sends them out in timed intervals. I called them and they wouldn't help me with the mail function and all they said was they don't support 3rd party scripting and to use their scripts..............OR.......... PURCHASE DEDICATED HOSTING at an additional cost of $30.00/mth!!!! I reconfigured my form/function to use my GoDaddy email address with my contact form using the mail() function and it now works, strange? NOT! I did some research into this and it seems that GoDaddy is preventing their users from using the mail function, unless it goes to a GoDaddy email address. There are quite a few GoDaddy customers with this issue, worked for a bit then stopped working with similar calls to technical support with similar responses. I was told by the tech support guy that they do support PEAR Mail, I guess I will have to figure that one out but for the time being sending the form data to my GoDaddy email account then retrieving it from within Outlook will do for now or as long as GoDaddy allows it! Thanks to all for replies, Chuck Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314794 Share on other sites More sharing options...
PFMaBiSmAd Posted February 5, 2012 Share Posted February 5, 2012 Because you are not specifying a From: email address header, it's likely that the MTA's relaying restrictions are not being met (either the To: address or the From: address must normally be a valid mail box hosted on the sending mail server.) Try putting in a From: email address header that contain your godaddy hosted email address and see if it will send to an outside To: email address. Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314800 Share on other sites More sharing options...
tinwakr Posted February 5, 2012 Author Share Posted February 5, 2012 Hi PFMaBiSmAd, Did that, still didn't work. Thanks, Chuck Quote Link to comment https://forums.phpfreaks.com/topic/256415-mail-function-woes/#findComment-1314802 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.