Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contact form - Email not sending

Status
Not open for further replies.

RP1America

Technical User
Aug 17, 2009
221
US
I have a simple contact form that I cannot seem to get to send me an email. Any suggestions?

Thanks!

Code:
<!-- Begin Form -->
<div id="formsize">
<form method="post" action="sendmail.php">
<fieldset>
<legend>Contact Form</legend>
<img width="160" src="../images/contactus.gif" alt="Contact Form" height="160" id="formimage" /> <br />
<label>Your Name:</label><br />
<input name="name" id="name" /><br />
<label>Your Email:</label><br />
<input name="email" id="email" /><br />
<label>Phone Number:</label><br />
<input name="phone" id="phone" /><br /><br />
<label>Your Message:</label><br />
<textarea cols="40" rows="10" name="message" id="message"></textarea><br /><br />
<input value="Submit" type="submit" /> 
</fieldset> 
</form>
</div>
<!-- End Form -->

Code:
<?php

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

$to = 'info@abcsolutions.com';
$subject = "Contact Us Form from $name";
$comments = "Name: $name\nEmail: $email\nPhone: $phone\n\nMessage: $message";
$headers = "From: $email";

mail($to, $subject, $comments, $headers);

header( "Location: thankyou.html" );

?>
 
your script has the potential to act as a mail gateway for spammers. please read up on security practices before putting this into use on any accessible website.

you should add a "\r\n" at the end of your headers.

however there is nothing that would stop your mail from sending, I believe. The problem probably lies in the configuration of your mailserver (assuming you have error reporting turned on and displaying and that no errors are reported).

If you are using unix make sure that your php.ini file properly declares the location of your sendmail binary.

if you are using windows, make sure that your php.ini file points to an active smtp server that accepts connections from your webserver with your credentials.
 
I've tried another email address and it is not working either, so it seems the problem may still lie in the php.

BTW, I have added reCAPTCHA. Thanks for the tip jpadie!

Any other ideas on why I would not be receiving the email?
 
BTW, I have added reCAPTCHA. Thanks for the tip jpadie!

oh dear. that does not stop your script being a remailer. security is not a topic that you can read up on in an hour. at the very least read everything on this site
I've tried another email address and it is not working either, so it seems the problem may still lie in the php.

the to address has zero impact whatsoever. the php script is fine. The issue lies in the areas I posted about above.
If this is not meaningful to you then you may not be at a level where we can help and you should talk instead to your network administrator.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top