Simple questions, but important:
What type of server are you running it on? (Apache, windows?)
Are you running it on a “live” server, or from a personal (local) installation?
Are you sure you are not sending emails? If you are on apache with valid PHP, on a real live server that is actually capable of sending email (your local installation probably won’t be if that’s what you’re doing), then it could be that your email is being filtered out by your spam filter.
I’m on apache server now and using the script in live server.
I also checked my spam folder but nothing is there.
I thought it could because of I didn’t touch “$EmailFrom = “email@example.com”;”
then I change it to mine but again it didn’t work.
Does PHP’s mail() work correctly?
$to = ‘firstname.lastname@example.org';
$subject = ‘the subject';
$message = ‘hello';
$headers = ‘From: email@example.com‘ . “rn” .
‘Reply-To: firstname.lastname@example.org‘ . “rn” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);
I have these lines:
$EmailFrom = “email@example.com”;
$EmailTo = “firstname.lastname@example.org”;
$Subject = “Nice & Simple Contact Form by CSS-Tricks”;
$Name = Trim(stripslashes($_POST));
$Subject = Trim(stripslashes($_POST));
$Email = Trim(stripslashes($_POST));
$Message = Trim(stripslashes($_POST));
but yours is different from mine I think.
Yes, mine is different from yours. That’s because I want you to isolate components of the application in order to work out where it is going wrong.
The script I posted uses the mail() function and some variables and nothing else. If it doesn’t work, then the problem is somewhere in that function. If that works, then the problem is elsewhere.
The application works. I have installed it on my own domain and I receive emails fine. Therefore there is something on your end that is different.
To test my script, create a blank php file (call it testmail.php or something), copy the code I posted into it and save it into your domain. Then visit the script. mail() will then be used as expected and you can see if you receive the email.
> I want to use the mail script as chris’s and show a message for success or error after sending mails.
I understand that. But you say you have uploaded the scripts onto the server and when you complete the form it gives you the success message, but you don’t receive the email.
I am trying to help you establish what isn’t working. You say you are on an actual server and I assume it is running PHP fine. Mail isn’t being filtered out as spam and I know that Chris’ scripts ([here](http://css-tricks.com/nice-and-simple-contact-form/ “”)) work on my server, so the fault isn’t with them.
The only function that I can see being a problem is mail(), as everything else is string manipulation or would lead to an error and wouldn’t (I think) have produced the “Your message has been sent!” feedback when you use it.
So, I posted code above that cut out a lot of code so that you could test, on its own, whether mail() was working on your server. All I want you to do is save that code in a PHP file (on your server) then visit the page. You won’t see anything in your browser, but it should send an email to the address you enter. If it doesn’t, we know the problem is with the mail() function and you’ll probably need to talk to your web host about resolving it. If it does work, we can dig deeper into why the script isn’t working for you.
You could try your hand at mine I put together…
I uploaded the file mail.php holding your codes on my hosting but it didn’t work then I decided to check in another hosting and it worked. So as you said it was about my hosting and I should talk with the moderators to see what they can do for me.
Thank you so much for these kind helps! I really apperciate your work.
You must be logged in to reply to this topic.