city_baby Posted November 12, 2010 Share Posted November 12, 2010 so, I've been trying to build a contact form for about a week now. straight. no kidding. I'm entirely new to php and basically know nothing more than i can assume based on other scripting/coding experience. I know there's probably answers to similar questions all over the place, but I've been trying literally hundreds of different pre-built forms guaranteed to work and solutions to others' problems, etc etc and not a single one has operated correctly for me. I can't really do anything with a "you should try this/that approach" answer, nor can I be assumed to know anything about php; I pretty much just need someone to fix whatever the problem is and paste it back to me as this is the only thing keeping me from launching the site. this is what prints when trying to submit with the dropdown on the default value: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 There was an err0r processing your request. Please notify [email protected] & include details of what you did [wrong]. this prints when any item other than the default is selected in the dropdown: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5810110\html\contact\contact.php on line 32 Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\5810110\html\contact\contact.php on line 33 There was an err0r processing your request. Please notify [email protected] & include details of what you did [wrong]. http://email.about.com/cs/standards/a/smtp_error_code_2.htm specifically states to ignore both these errors, yet http://cr.yp.to/docs/smtplf.html specifically states that it's a fault of mine. here's the html: <div id="formHolder"> <form method="post" action="contact.php"> <table class="contactTable" align="center"> <tr> <td> Subject: </td> <td> <select name="sendto"> <option value="bs from N1K.com">General Inquiry</option> <option value="JOB OFFER">Design Contract</option> <option value="PURCHASE ORDER">Purchase Order/Offer</option> </select> </td> </tr> <tr> <td><font color=red>*</font>Name:</td> <td><input size=25 name="Name"></td> </tr> <tr> <td><font color=red>*</font>Email:</td> <td><input size=25 name="Email"></td> </tr> <tr> <td>Company:</td> <td><input size=25 name="Company"></td> </tr> <tr> <td>Phone:</td> <td><input size=25 name="Phone"></td> </tr> <tr> <td>Subscribe to<br> mailing list: </td> <td><input type="radio" name="list" value="No"> Pf, nothx.<br> <input type="radio" name="list" value="Yes" checked> H3X Y34!<br> </td> </tr> <tr> <td colspan=2>Message:</td> </tr> <tr> <td colspan=2 align=center> <textarea name="Message" rows=5 cols=35></textarea> </td> </tr> <tr> <td colspan=2 align=center> <input type=submit name="send" value="Submit"> </td> </tr> </table> </form> </div><!-- END formHolder --> and here's the php: <?php $to = "[email protected]" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = $_REQUEST['sendto'] ; $fields = array(); $fields{"Name"} = "Name"; $fields{"Company"} = "Company"; $fields{"Email"} = "Email"; $fields{"Phone"} = "Phone"; $fields{"list"} = "Mailing List"; $fields{"Message"} = "Message"; $body = "I have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: [email protected]"; $subject2 = "autoconfirm from neurot1k.com"; $autoreply = "Thanks for the contact, I'll get back to you as soon as possible, usually within 48 hours. If you have any more questions, please try me on AIM: ycleptCrux"; if($from == '') { print "You have not entered an email, please go back and try again"; } else { if($name == '') { print "You have not entered a name, please go back and try again"; } else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) { print "Thanks, I'll get back to you as soon as possible."; } else { print "There was an err0r processing your request. Please notify [email protected] & include details of what you did [wrong]."; } } } ?> the form was copy/pasted from http://php.about.com/od/phpapplications/ss/form_mail.htm and then respective variables were changed (email address, dropdown fields, etc). I didn't think it'd be SUCH a problem to copy/paste a pre-written block of code from About.com... HUGE thanks in advance to anyone willing to helo. Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/ Share on other sites More sharing options...
micah1701 Posted November 12, 2010 Share Posted November 12, 2010 perhaps your SMTP server has over zealous spam filtering. what if you change: <option value="JOB OFFER">Design Contract</option> <option value="PURCHASE ORDER">Purchase Order/Offer</option> to <option value="Design Contract">Design Contract</option> <option value="Some other Value without spam-like keywords">Purchase Order/Offer</option> Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1133446 Share on other sites More sharing options...
city_baby Posted November 12, 2010 Author Share Posted November 12, 2010 ohhhh that makes sense ill have to try n report back when im home. but that still leaves the error 451 issue... Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1133625 Share on other sites More sharing options...
city_baby Posted November 13, 2010 Author Share Posted November 13, 2010 (sorry for doublepost but there's no edit...) that didn't work. changed them to a myriad of different things and it still returned both errors in each situation. I use GoDaddy, so secureserver.net is my SMTP right? idk how strict they are but the name sounds pretty standard, they shouldnt be filtering like that should they? Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1133676 Share on other sites More sharing options...
city_baby Posted November 18, 2010 Author Share Posted November 18, 2010 seriously? bump? Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1135924 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 Have you bothered to check with the hosting company about this? Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1135934 Share on other sites More sharing options...
city_baby Posted November 20, 2010 Author Share Posted November 20, 2010 perhaps your SMTP server has over zealous spam filtering. I use GoDaddy yeah, they said they have no idea but it's not them. Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1137066 Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2010 Share Posted November 20, 2010 The 451 error leads to this link - http://cr.yp.to/docs/smtplf.html and is due to you using just \n instead of \r\n Given that you are getting the $subject from the form and you have likely already sent a number of test emails to the To: address, the receiving mail server may have added your sending mail server and the subject lines you were using to a black-list and is voting all email from it as spam and sending back the 554 response code. Also, by allowing the subject to be entered from external data and the external email address to be put into the header field without any validation, it is possible that bot scripts have been sending email through your script, which has gotten your domain added to various spam databases. Another possibility is that the receiving mail server is validating that the From: address is host at the sending mail server (which it should be) and/or you don't have an SPF record at the domain in the From: address (because it can be any arbitrary email address of the visitor filling in the form and you don't have the ability to know or set the SPF record at the domain) that authorizes your sending mail server to send email for that domain name. You should be putting an email address hosted at the sending mail server into the From: address and put the arbitrarily entered email address in to the Reply-to: address. You should also be validating the entered email address to prevent mail header injection. Quote Link to comment https://forums.phpfreaks.com/topic/218451-simple-contact-form-php-n00b/#findComment-1137075 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.