Im looking for a little help,
I am in the process of building a website and i want the contact form data to be sent to an email account.
After looking at a tutorial on how to send my html form data to php i have hit a problem where the email always goes into the outlook accounts junk folder. I suspsect it may be the code i have used anyway any help would be very appreciated!
Code so far:
PHP Code:<?php
$field_name = $_POST['mps-name'];
$field_email = $_POST['mps-email'];
$field_tel = $_POST['mps-tel'];
$field_pcode = $_POST['mps-pcode'];
$field_chooseemail = $_POST['mps-choose-email'];
$field_choosetel = $_POST['mps-choose-tel'];
$field_time = $_POST['mps-time'];
$field_message = $_POST['mps-message'];
$mail_to = 'dmc-webdesign@live.com';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Telephone: '.$field_tel."\n";
$body_message .= 'Postcode: '.$field_pcode."\n";
$body_message .= 'Contact by Email: '.$field_chooseemail."\n";
$body_message .= 'Contact by Tel: '.$field_choosetel."\n";
$body_message .= 'Best time to call: '.$field_time."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you within 24 Hours.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to dmcgowan@sky.com');
window.location = 'contact.html';
</script>
<?php
}
?>Many ThanksCode:<form name="mpsForm" action="contact.php" method="post"> Name<input type="text" name="mps-name"><br> Email Address<input type="email" name="mps-email"><br> Contact Number<input type="tel" name="mps-tel"><br> Postcode<input type="text" name="mps-pcode"><br> How should we contact you?<br> <input type="checkbox" name="mps-choose-email" value="Email">Email<br> <input type="checkbox" name="mps-choose-tel" value="Phone">Phone<br> Best time to call: <input type="text" name="mps-time" id="callTime"><br> <textarea name="mps-message" rows="5" cols="45"></textarea><br> <input type="submit" value="Send" name="submit"> </form>


Reply With Quote

Bookmarks