Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP mail sending with Javascript
    text
    copied!<p>I'm having a problem with sending a mail from my site to my own Outlook.com account, the problem is that if some one is using my contact form it doesn't send the mail to me.</p> <p>Normally everything in PHP with the mail process would work but this time I wonted to use JavaScript with it so my form does everything automatically. I'm not getting an error, I'm getting the message that the e-mail was send.</p> <pre><code> //Contact script. if(isset($_POST['submit'])) { $sName = trim($_POST['author']); $sEmail = trim($_POST['email']); $sMessage = trim($_POST['comment']); if(empty($sName)) { $nameError = 'U bent uw naam vergeten'; $hasError = true; } if(empty($sEmail)) { $emailError = 'U bent uw email adres vergeten'; $hasError = true; } elseif(!filter_var($sEmail, FILTER_VALIDATE_EMAIL)) { $emailError = 'Uw mail adres is niet geldig!'; $hasError = true; } if(empty($sMessage)) { $commentError = 'U hebt geen bericht opgegeven'; $hasError = true; } //Mail versturen. if(!isset($hasError)) { $weNaam = 'RASolutions'; $eiMail = 'info@rasolutions.nl'; $erMail = 'info@rasolutions.nl'; $nAfzender = 'RASolutions'; $afMail = '**********@.nl'; $baMail = 'info@seobeheer.nl'; $aHtml = true; // De headers samenstellen $headers = 'From: &lt;' . $weNaam . '&gt; '. PHP_EOL ; $headers .= 'Reply-To: &lt;' . $nAfzender . '&gt; &lt;' . $eiMail . '&gt;' . PHP_EOL; $headers .= ($baMail != '') ? 'Bcc: &lt;' . $baMail . PHP_EOL : ''; $headers .= 'X-Mailer: PHP/' . phpversion() . PHP_EOL; $headers .= 'X-Priority: Normal' . PHP_EOL; $headers .= ($aHtml) ? 'MIME-Version: 1.0' . PHP_EOL : ''; $headers .= ($aHtml) ? 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL : ''; $sBericht = " Beste, &lt;br /&gt; &lt;br /&gt; er is gebruik gemaakt van het contact formulier op RASolutions.&lt;br /&gt; Het mail adres dat hiervoor is gebruikt: &lt;strong&gt;".$sEmail."&lt;/strong&gt;, de naam van degene is &lt;strong&gt;".$sName."&lt;/strong&gt;.&lt;br /&gt; &lt;br /&gt; &lt;i&gt;Onderstaande het bericht:&lt;/i&gt; ".$sMessage." &lt;br /&gt; &lt;br /&gt; Met vriendelijke groet, &lt;br /&gt; RASolutions helpdesk. "; //Verzonden. $mail = mail($afMail, "Contact || RASolutions", $sBericht, $headers); $emailSent = true; } } </code></pre> <p>My HTML form and the JS part:</p> <pre><code> &lt;?php if(isset($emailSent) &amp;&amp; $emailSent == true) { ?&gt; &lt;div class="succes closable"&gt;Uw mail is succesvol verstuurd! U zal in 48 uur een antwoord krijgen.&lt;/div&gt; &lt;?php } if(isset($hasError) || isset($captchaError) ) { ?&gt; &lt;div class="warning closable"&gt;Er zijn wat problemen opgetreden.&lt;/div&gt; &lt;?php } ?&gt; &lt;form id="contact-us" action="" method="post"&gt; &lt;p&gt; &lt;label for="author"&gt;Naam&lt;/label&gt; &lt;input id="author" class="aqua_input" name="author" type="text" placeholder=""/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="email"&gt;Email&lt;/label&gt; &lt;input id="email" class="aqua_input" name="email" type="email" placeholder=""/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="comment"&gt;Bericht&lt;/label&gt; &lt;textarea id="comment" rows="8" class="aqua_input" name="comment" placeholder=""&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;p class="form-submit"&gt; &lt;input name="submit" type="submit" id="submit" value="Verstuur" class="sm_button"&gt; &lt;/p&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; &lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!-- $(document).ready(function() { $('form#contact-us').submit(function() { $('.warning closable').remove(); var hasError = false; $('.aqua_input').each(function() { if($.trim($(this).val()) == '') { var labelText = $(this).prev('label').text(); $(this).parent().append('&lt;div class="warning closable"&gt;U bent uw '+labelText+' vergeten op te geven&lt;/div&gt;'); $(this).addClass('inputError'); hasError = true; } else if($(this).hasClass('email')) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(!emailReg.test($.trim($(this).val()))) { var labelText = $(this).prev('label').text(); $(this).parent().append('&lt;div class="warning closable"&gt;&lt;strong&gt;Helaas!&lt;/strong&gt; Uw ingevoerde waardes zijn ongeldig: '+labelText+'&lt;/div&gt;'); $(this).addClass('inputError'); hasError = true; } } }); if(!hasError) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput, function(data) { $('form#contact-us').slideUp("fast", function() { $(this).before('&lt;div class="success closable"&gt;&lt;strong&gt;Bedankt!&lt;/strong&gt; U zal in 48 uur een antwoord krijgen. &lt;/div&gt;'); }); }); } return false; }); }); //--&gt;!]]&gt; &lt;/script&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