Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP mail function, whats wrong here?
    text
    copied!<p>The following code sends me an email holding the following variables. One of the last if statements says if(mail) then echo "You will be contacted soon". When the script runs I get echoed back "You will be contacted soon", however, I never receive an email.</p> <p>I do have a smaller contact script (posted after this first and larger one) that does work.</p> <p>Note: contants.php and functions.php are both included and work fine WEBMASTER_EMAIL is defined in contanstants.php and is correct, because my smaller contact script uses the same variable, and emails me fine.</p> <p>Thanks for the help</p> <pre><code> &lt;?php // pull constant variables include("php/constants.php"); error_reporting (E_ALL ^ E_NOTICE); $post = (!empty($_POST)) ? true : false; if($post) { include ("php/functions.php"); } // general info $name = stripslashes($_POST['contact']); $phone = $_POST['phone']; $email = trim($_POST['email']); $time_to_reach = $_POST['time-to-reach']; // what the best time to reach them? // delivery info $delivery_address = $_POST['del-address']; $delivery_city = $_POST['del-city']; $delivery_state = $_POST['del-state']; $delivery_zip = $_POST['del-zip']; // moving city info if applicable $moving_address = $_POST['move-address']; $moving_city = $_POST['move-city']; $moving_state = $_POST['move-state']; $moving_zip = $_POST['move-zip']; // date needed $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; // how long do you need the storage? $storage_length = $_POST['time-length']; // how many containers do you need? $quantity_containers = $_POST['number-of-containers']; // how did you hear about us? $tracker = $_POST['tracker']; // message $message_holder = htmlspecialchars($_POST['message']); $error = ''; // check general info if(!$name) { $error .= 'Please enter your name.&lt;br /&gt;'; } if(!$email) { $error .= 'Please enter an e-mail address.&lt;br /&gt;'; } if($email &amp;&amp; !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.&lt;br /&gt;'; } if(!$time_to_reach) { $error .= 'Please select the best time to reach you.&lt;br /&gt;'; } // check delivery info if(!$delivery_address) { $error .= 'Please enter you current address.&lt;br /&gt;'; } if(!$delivery_city) { $error .= 'Please enter your current city.&lt;br /&gt;'; } if(!$delivery_state) { $error .= 'Please enter your current state.&lt;br /&gt;'; } if(!$delivery_zip) { $error .= 'Please enter your current zip code.&lt;br /&gt;'; } // check date needed if(!$month) { $error .= 'Please enter the approximate date you need the storage.&lt;br /&gt;'; } if(!$day) { $error .= 'Please enter the approximate date you need the storage.&lt;br /&gt;'; } if(!$year) { $error .= 'Please enter the approximate date you need the storage.&lt;br /&gt;'; } // check length of time needed if(!$storage_length) { $error .= 'Approximatly how long will you need the storage unit for?&lt;br /&gt;'; } // check quantity of storages if(!$quantity_containers) { $error .= 'How many containers will you need?&lt;br /&gt;'; } // check advertising tracker if(!$tracker) { $error .= 'Please let us know how you\'ve heard of us.&lt;br /&gt;'; } // check message (length) if(!$message_holder || strlen($message_holder) &lt; 10) { $error .= "Please enter your message. It should have at least 10 characters.&lt;br /&gt;"; } // build email message $message = "Name: {$name} Phone: {$phone} Email: {$email} Best time to reach: {$time_to_reach}\n ----------------------------------------------------- Delivery address: {$delivery_address} {$delivery_city}, {$delivery_state} {$delivery_zip} Moving address: {$moving_address} {$moving_city}, {$moving_state} {$moving_zip} ----------------------------------------------------- Date needed: {$month}/{$day}/{$year} Length of time needed: {$storage_length} Number of containers: {$quantity_containers} Where did you hear about us? {$tracker}\n Message: {$message_holder}\n"; if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: residential-quote@stocor.com\r\n" ."Reply-To: ".$name."&lt;".$email."&gt;\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { echo '&lt;p&gt;Thank you, you will be contacted soon.&lt;/p&gt;'; } } else { echo '&lt;div class="notification_error"&gt;'.$error.'&lt;/div&gt;'; } ?&gt; </code></pre> <p>The following script, contact script, does work meaning I receive an email.</p> <pre><code>&lt;?php // pull constant variables include("php/constants.php"); error_reporting (E_ALL ^ E_NOTICE); $post = (!empty($_POST)) ? true : false; if($post) { include ("php/functions.php"); } // variables $name = stripslashes($_POST['name']); $phone = $_POST['phone']; $email = trim($_POST['email']); $tracker = $_POST['tracker']; $message_holder = htmlspecialchars($_POST['message']); $error = ''; // check name if(!$name) { $error .= 'Please enter your name.&lt;br /&gt;'; } // check email if(!$email) { $error .= 'Please enter an e-mail address.&lt;br /&gt;'; } // validate email if($email &amp;&amp; !ValidateEmail($email)) { $error .= 'Please enter a valid e-mail address.&lt;br /&gt;'; } // check advertising tracker if(!$tracker) { $error .= 'Please let us know how you\'ve heard of us.'; } // check message (length) if(!$message_holder || strlen($message_holder) &lt; 10) { $error .= "Please enter your message. It should have at least 10 characters.&lt;br /&gt;"; } // build email message $message = "Name: {$name} \n Phone: {$phone} \n Email: {$email} \n Where did you hear about us? {$tracker}\n\n Message: {$message_holder}\n"; if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: contact@stocor.com\r\n" ."Reply-To: ".$name."&lt;".$email."&gt;\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) { //header("Location: thank_you.php"); echo "Thank you. You will be contacted soon."; } } else { echo '&lt;div class="notification_error"&gt;'.$error.'&lt;/div&gt;'; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload