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.
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.
//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 = '[email protected]';
$erMail = '[email protected]';
$nAfzender = 'RASolutions';
$afMail = '**********@.nl';
$baMail = '[email protected]';
$aHtml = true;
// De headers samenstellen
$headers = 'From: <' . $weNaam . '> '. PHP_EOL ;
$headers .= 'Reply-To: <' . $nAfzender . '> <' . $eiMail . '>' . PHP_EOL;
$headers .= ($baMail != '') ? 'Bcc: <' . $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, <br />
<br />
er is gebruik gemaakt van het contact formulier op RASolutions.<br />
Het mail adres dat hiervoor is gebruikt: <strong>".$sEmail."</strong>, de naam van degene is <strong>".$sName."</strong>.<br />
<br />
<i>Onderstaande het bericht:</i>
".$sMessage."
<br /> <br />
Met vriendelijke groet, <br />
RASolutions helpdesk.
";
//Verzonden.
$mail = mail($afMail, "Contact || RASolutions", $sBericht, $headers);
$emailSent = true;
}
}
My HTML form and the JS part:
<?php
if(isset($emailSent) && $emailSent == true)
{
?>
<div class="succes closable">Uw mail is succesvol verstuurd! U zal in 48 uur een antwoord krijgen.</div>
<?php
}
if(isset($hasError) || isset($captchaError) )
{
?>
<div class="warning closable">Er zijn wat problemen opgetreden.</div>
<?php
}
?>
<form id="contact-us" action="" method="post">
<p>
<label for="author">Naam</label>
<input id="author" class="aqua_input" name="author" type="text" placeholder=""/>
</p>
<p>
<label for="email">Email</label>
<input id="email" class="aqua_input" name="email" type="email" placeholder=""/>
</p>
<p>
<label for="comment">Bericht</label>
<textarea id="comment" rows="8" class="aqua_input" name="comment" placeholder=""></textarea>
</p>
<p class="form-submit">
<input name="submit" type="submit" id="submit" value="Verstuur" class="sm_button">
</p>
</form>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(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('<div class="warning closable">U bent uw '+labelText+' vergeten op te geven</div>');
$(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('<div class="warning closable"><strong>Helaas!</strong> Uw ingevoerde waardes zijn ongeldig: '+labelText+'</div>');
$(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('<div class="success closable"><strong>Bedankt!</strong> U zal in 48 uur een antwoord krijgen. </div>');
});
});
}
return false;
});
});
//-->!]]>
</script>