tpl41803 Posted December 4, 2008 Share Posted December 4, 2008 hey everyone, been looking around on these forms for a while now, but never posted ive only been working with php for about a month now, and i am literally pulling my hair out trying to make a simple contact form submit information to me via email using the mail () function i wrote the script from several different sources, it's my own technically, but i followed tutorials in books i have and a tutorial i read on thesitewizard.com about sending mail through forms. I've found a lot of conflicting information and tried my own twists on things to make the page suitable to me. but, the bottom line is that when i strip the code of everything except the mailing action, it still doesnt work. the form: <form name="contact" method="post" action="contact_submit.php"> <table> <tr> <td></td><td><span class="alert">*</span> denotes a required field.</p> </tr> <tr> <td>Name<span class="alert">*</span></td> <td><input type="text" name="name" /></td> </tr> <tr> <td>E-Mail<span class="alert">*</span></td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone" /></td> </tr> <tr> <td>Comments<span class="alert">*</span></td> <td><textarea name="comments" rows="5" cols="#"></textarea></td> </tr> <tr> <td colspan="2" class="center"><input type="submit" value="Submit" class="button"/> <input type="reset" class="button" /></td> </tr> </table> </form> and the contact_submit.php script: <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $comments = $_REQUEST['comments'] ; if (!isset($_REQUEST['email'])) { header( "Location: contact.php"); } elseif (empty($name) || empty($email) || empty($comments)) { require_once('contact_error.inc'); } elseif ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { require_once('contact_error.inc'); } else { mail( "tpl41803@aol.com", "Comment from CARS Contact Form", $comments, "From: $name at $email or $phone" ); require_once('contact_complete.inc'); } ?> I'm not a professional webdesigner, I've just put together a small site to the best of my ability and I'd appreciate any suggestions at all. thanks Quote Link to comment https://forums.phpfreaks.com/topic/135463-solved-need-help-with-mail-function-please/ Share on other sites More sharing options...
revraz Posted December 4, 2008 Share Posted December 4, 2008 You can't do this "From: $name at $email or $phone" Use a valid email from your domain from the FROM: field "From: you@yourdomain.com" Quote Link to comment https://forums.phpfreaks.com/topic/135463-solved-need-help-with-mail-function-please/#findComment-705874 Share on other sites More sharing options...
tpl41803 Posted December 5, 2008 Author Share Posted December 5, 2008 thanks for the reply-- i changed the code around a bit, now sending the information to an email address at my domain, and using a different email at my domain for the 4th header -- so it now reads: mail( "email@mydomain.com", "Comment from CARS Contact Form", "$comments from $name at $email or $phone", "From: email@mydomain.com" ); still no luck with an email going though I'm thinking it might possibly be a problem with the php.ini settings, which I have set as: SMTP = localhost sendmail_path = /usr/sbin/sendmail Quote Link to comment https://forums.phpfreaks.com/topic/135463-solved-need-help-with-mail-function-please/#findComment-706990 Share on other sites More sharing options...
revraz Posted December 6, 2008 Share Posted December 6, 2008 Check your error logs. Quote Link to comment https://forums.phpfreaks.com/topic/135463-solved-need-help-with-mail-function-please/#findComment-707245 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.