bscyb Posted June 7, 2011 Share Posted June 7, 2011 hello i have a contact form on my site and via PHP i send the message to my e-mail but i think something is wrong with PHP script cause i dont get any e-mail when i write a message heres the html contact form code html <form name="cform" action="form-to-email.php" method="post" onsubmit="return validate()"> <h4>Contact Form</h4> <p>Στείλτε μας τις απορίες και τα σχόλια σας <br /> </p> <ol> <li> <label for="name"> <font color="maroon">*</font>Name:</label> <input type="text" name="name" id="name" tabindex="1" /> </li> <li> <label for="email"><font color="maroon">*</font>Email:</label> <input type="text" name="email" id="email" tabindex="2" /> </li> <li> <label for="message"><font color="maroon">*</font>Message:</label> <textarea name="message" id="message" tabindex="3" rows="3" ></textarea> </li> <li id="send"> <button type="submit" >Send</button> </li> </ol> </form> and heres the PHP script <?php $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message']; $email_from = 'nick_171717@hotmail.com'; $email_subject = "New Form submission"; $email_body = "You have received a new message from the user $name.\n". "Here is the message:\n $message". $to = "nick_171717@hotmail.com"; $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to,$email_subject,$email_body,$headers); header('Location: index.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/ Share on other sites More sharing options...
RussellReal Posted June 7, 2011 Share Posted June 7, 2011 You shouldn't spoof your visitor's emails, you should put the email in the reply-to, but you should create an email from YOUR domain name, like: alerts@yourDomain.com, to send emails, because most times when you send an email from your webserver with a different domain name, it goes straight to junkmail, sometimes not accepted at all.. Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226533 Share on other sites More sharing options...
fugix Posted June 7, 2011 Share Posted June 7, 2011 what mail server are you using to send the email? Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226534 Share on other sites More sharing options...
bscyb Posted June 7, 2011 Author Share Posted June 7, 2011 what mail server are you using to send the email? im new on PHP and i dont know allot of things im not using any mail server i work on eclipse i dont know if eclipse has embeded the mail function Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226535 Share on other sites More sharing options...
fugix Posted June 7, 2011 Share Posted June 7, 2011 in order to send mail using the mail() function. You will need to declare a valid SMTP (Simple Mail Transfer Protocol) in you php.ini file. When the mail() function attempts to send mail, it opens an SMTP socket in order to send the mail. I assume that you are using localhost to test your site? I recommend that you put your site on a recommended server that already has SMTP etc configured Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226541 Share on other sites More sharing options...
bscyb Posted June 7, 2011 Author Share Posted June 7, 2011 in order to send mail using the mail() function. You will need to declare a valid SMTP (Simple Mail Transfer Protocol) in you php.ini file. When the mail() function attempts to send mail, it opens an SMTP socket in order to send the mail. I assume that you are using localhost to test your site? I recommend that you put your site on a recommended server that already has SMTP etc configured ok i will put my site on a recommended server that has smtp but the PHP script has something wrong because i test it before some weeks when i had my site uploaded on 000webhost but it was not sending any e-mail Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226543 Share on other sites More sharing options...
fugix Posted June 7, 2011 Share Posted June 7, 2011 did you have error reporting on/check the error log for any errors that were triggered when the script was run? offhand, i dont see any errors that would cause your script to not send an email...my first guess would be a server issue Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226553 Share on other sites More sharing options...
bscyb Posted June 7, 2011 Author Share Posted June 7, 2011 No i didn't get any error after i put submit it goes me to other page that writes that message was send succesfully Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226555 Share on other sites More sharing options...
fugix Posted June 7, 2011 Share Posted June 7, 2011 unless someone else can spot an error, i cant. I would assume that it ws because your previous server host did not set up the mail server for you...I found a site that describes what to look for and how to set up you php.ini file to reflect your smtp mail server settings...http://php.devquickref.com/php-smtp-mail-auth-aaa-setup-php-ini.html Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226558 Share on other sites More sharing options...
bscyb Posted June 7, 2011 Author Share Posted June 7, 2011 ok i will try the guide you posted Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226593 Share on other sites More sharing options...
Pikachu2000 Posted June 7, 2011 Share Posted June 7, 2011 Javascript is NOT validation. All validation of data must be done server-side. A user can disable javascript in their browser, and send whatever values they want to your script without restriction. JS is really nothing more than a way to improve (or in some cases, destroy) convenience and usability. Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226596 Share on other sites More sharing options...
bscyb Posted June 7, 2011 Author Share Posted June 7, 2011 i posted this on the wrong topic now i modified the post :S Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226598 Share on other sites More sharing options...
fugix Posted June 7, 2011 Share Posted June 7, 2011 we can see by your onsubmit event that you are infact using JS to validate your form. While there are ways to work around a user having JS disabled, like using <noscript> tags, Pikachu is right in saying that it should never be used as validation. Quote Link to comment https://forums.phpfreaks.com/topic/238682-php-contact-form/#findComment-1226600 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.