Hi Everyone!
I’m new to web design and have created a PHP script for a site, which has a comment form to send as an email to a Gmail account. When on the site, it confirms the message has been sent and it is received in the Gmail inbox, but, the email only shows the headers and no content whatsoever… Can anyone help? I’m desperate now.
Any help greatly appreciated!
Here’s the PHP code :
<?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_message = $_POST['cf_message']; $mail_to = '[email protected]'; $subject = 'Message from a site visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\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 shortly.');
window.location = 'contact-us.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to [email protected]');
window.location = 'contact-us.html';
</script>
<?php
}
?>