AnthNE Posted June 25, 2007 Share Posted June 25, 2007 Hello, I am having a huge problem with getting a contact php script to work on my FastHosts Windows 2003 server and they are not very helpful and hoped someone would be able to advise me what to do with my script to get it to work. Apparently the form looks like it works fine but i never receive the email into my mail box, fast Hosts have said its because they have some filter thing on to stop spam and i need to a code to my script like: $ini_set("sendmail_from", "email@mydomain.com"); Now i dont understand the exact reason why the emails are not getting through but I am under the impression it has to be with the SMTP server or something and i need the code above and for the mails to show they are from my own domain if that makes sense, trouble is i have no idea what to change or anything as it was a script i got off net. Can anyone help me please, I have tried for hours to get it to work and i cant when i add the $ini code i get an error on the script when i click send says error on line 4 etc, a copy of the script i am using is below if anyone could sort this i would be very grateful as Fast Hosts are useless and simply tell me 'im sorry we can not supply support on php' why they cant supply a script is beyond me especially considering im not the only one having this problem!! <? $mailto = 'email@mydomain' ; $subject = "Query From Contact Form" ; $formurl = "http://www.mydomain.com/contact_form.htm" ; $errorurl = "http://www.mydomain.com/contact_form_error.htm" ; $thankyouurl = "http://www.mydomain.com/contact_form_thanks.htm" ; $uself = 1; // -------------------- DO NOT CONFIGURE BELOW --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $name = $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (empty($name) || empty($email) || empty($comments)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $name\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" ); header( "Location: $thankyouurl" ); exit ; ?> Quote Link to comment Share on other sites More sharing options...
AnthNE Posted June 26, 2007 Author Share Posted June 26, 2007 This is totally annoying me now no idea what to do, Someone please help!! Im ready to tear my hair out Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted June 26, 2007 Share Posted June 26, 2007 Before we start to debug your script, which includes more than sending an e-mail, I would like to see if you can send e-mail using PHP at all. Try to run the script below. It's a 'send an e-mail'-script stripped to the bare minimum. Change the e-mail to your own e-mail and report back whether it outputs: 'Mail sent successfully' or 'Mail _not_ sent' sendmail.php: <?php $to = 'your@email.com'; $subject = 'E-mail sent with PHP'; $message = 'Can I send an e-mail using PHP on my host?'; $headers = 'From: webmaster@example.com' . "\r\n"; $sendmail = mail($to,$subject,$message,$headers); if($sendmail) { echo 'Mail sent successfully'; } else { echo 'Mail _not_ sent'; } ?> I have tested the above code and I successfully received the mail on my g-mail. The reason why this is a good approach is because we don't know if the problem is your script or your host. So lets start by checking your host's e-mail capabilities with a script which works for sure Quote Link to comment 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.