PHP email form not sending email

This is a discussion on "PHP email form not sending email" within the PHP Forum section. This forum, and the thread "PHP email form not sending email are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 12th, 2007, 00:46
Junior Member
Join Date: May 2007
Location: Virginia
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
PHP email form not sending email

I'm brand new to PHP. I created an email / contact form (still testing on my localhost), but when I hit submit it doesn't send the email and doesn't redirect to my custom thank you page. I don't get an error; instead, the browser just keeps spinning as if it's trying to connect to something.

I took the PHP code from a tutorial (but it didn't show how to redirect to a thank you page, so I added that part from another tutorial). Any idea what I'm missing?

Thank you! - Kurt

The PHP:

Code: Select all
<?php
if($_POST['action'] == "send"){
$message = "";
$message .= "User has filled in the Mail form at " . date("H:i") . " on " . date("m/d/Y") . "\n\n";
$message .= "Name: " . $_POST['name'] . "\n";
$message .= "Email: " . $_POST['email'] . "\n";
$message .= "Subject: " . $_POST['subject'] . "\n";
$message .= "Message: " . $_POST['message'] . "\n";
$to = "tears@oldmencrying.com";
$subject = "User has filled in the Mail Form";
$headers = "From: Mail Form <mailform@oldmencrying.com>\r \n";
$headers .= "X-Priority: 1 \r \n";
$headers .= "X-MSMail-Priority: High";
// Send email and direct browser to confirmation page
mail($to,$subject,$message,$headers);
header( "Location: http://www.oldmencrying.com/thankyou.html" );
}
?>
The HTML:

Code: Select all
<div id = "contactform">
 
<form action="contact.php" method="post" enctype="multipart/form-data">
 
   <fieldset>
      <legend>Personal information</legend>
         <label for="name">Name</label>
         <input name="name" id="name" type="text" size="50" maxlength="50" />
         <label for="email">E-mail</label>
         <input name="email" id="email" type="text" size="50" maxlength="50" />
     <legend>Message</legend>
         <label for="subject">Subject</label>
         <input name="subject" id="subject" type="text" size="50" maxlength="50" />
         <label for="message">Message</label>
         <textarea name="message" cols="50" rows=7" id="message"></textarea>
         <input class="button" type="submit" name="send" value="Send message" />
 
         <input type="hidden" name="action" value="send" />
    </fieldset>
 
</form>   
 
</div>
Reply With Quote

  #2 (permalink)  
Old Oct 12th, 2007, 04:26
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP email form not sending email

If you're testing locally, you probably don't have your mail program set up. See:

http://www.w3schools.com/php/php_ref_mail.asp
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP mail() --> Making a Form / Validating Input / Sending an email c010depunkk PHP Forum 4 Jan 17th, 2008 06:35
[SOLVED] sending email once form submitted Emzi PHP Forum 5 Nov 21st, 2007 14:25
sending form info to email eon201 PHP Forum 2 Oct 26th, 2007 15:34
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
About sending form-data to an email address a.jenery Web Page Design 4 Mar 3rd, 2006 12:17


All times are GMT. The time now is 05:43.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43