Jump to content

Emailing feedback using PHP


lukesb

Recommended Posts

Hi

 

I'm having no luck getting my PHP email sending to work. I have pasted the code below. If any one could help I'd really appreciate it..!

 

HTML

<div class="container">
    <div id="contactFormContainer">
        <div id="contactForm">
        	<div class="loader"></div>
		<div class="bar"></div>
            <form action="mail.php" class="contactForm" name="cform" method="post">
                <p>Talk to us about anything. If you have any feedback, ideas, or <br />there is anything else you want to say, we’ll get back to you shortly.</p>
                <div class="input_boxes">
                    <p><label for="name">Name</label><span class="name-missing">Please enter your name...</span><br />
                    <input id="name" type="text" value="" name="name" /></p>
                    <p><label for="e-mail">E-mail</label><span class="email-missing">Please enter a valid e-mail...</span><br />
                    <input id="e-mail" type="text" value="" name="email" /></p>
                    <p><label for="message">Feedback</label><span class="message-missing">Tell us your thoughts...</span><br />
                    <textarea id="message" rows="" cols="" name="message"></textarea></p>
                 </div>   
                 <input class="submit" type="submit" name="submit" value="Submit Form" onfocus="this.blur()"  />
            </form>
      </div>
      <div class="contact"></div>    
  </div>

 

mail.php

<?php 
//variables 
$name = $_POST['name']; 
$email = $_POST['email']; 
$message = nl2br($_POST['message']); 
//date 
$todayis = date("l, F j, Y, g:i a") ; 
//set title 
$subject = "Message from Your Website"; 
$body = "From $name, \n\n$message"; 
$headers = 'From: '.$email.'' . "\r\n" . 
    'Reply-To: '.$email.'' . "\r\n" . 
    'Content-type: text/html; charset=utf-8' . "\r\n" . 
    'X-Mailer: PHP/' . phpversion(); 

//email address 
mail("[email protected]", $subject, $body, $headers); 
?> 
<!--Display a thankyou message in the callback --> 
<div id="mail_response"> 
    <h3>Thank you <?php echo $name ?>!</h3><br /> 
    <p>We will answer your message soon as possible.</p><br /><br /><br /> 
    <h5>Message sent on: </h5> 
    <p><?php echo $todayis ?></p> 
</div>

 

I don't get any error messages, it just doesn't send the mail or pass on the sent message...

 

Cheers..!

 

Luke

 

 

Link to comment
https://forums.phpfreaks.com/topic/200991-emailing-feedback-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.