PHP mail function

software development

#1

I am using the PHP mail function in my website, but it doesnt seem to work. Is there anything I need to set up before I use this function? Its not giving an error or anything… just nothing is happening. This is what it looks like-

mail(’$email’,’$subject, $date’,stripslashes($message),$headers);

Any help is appreciated


#2

[quote]I am using the PHP mail function in my website, but it doesnt seem to work. Is there anything I need to set up before I use this function? Its not giving an error or anything… just nothing is happening. This is what it looks like-

mail(’$email’,’$subject, $date’,stripslashes($message),$headers);

Any help is appreciated
[/quote]
Remove the quotes a single quote states to take the string literally, therefore echo ‘$email’ would print $email not the value that the varable $email holds.
Your code should be:
$to=‘email@domain.com’;
$subject=“a message from my website”;
$body=htmlenities($message);
$header=‘From: email@domain.com’;
mail ($to, $subject, $body, $header);

Better yet, don’t use the header, I found out that it is possible for a users to add to the header. What I did was place the From: field and the remote IP inside the body of the message. But this was for emails to me only. Then should anyone spam me with the contact page, I knew their ip address to add to the htaccess file for blocking.
Hope this helps,
Silk


#3

Thanks silk, that helped alot. I knew about the quotes my brain just wasnt registering it for some reason.


#4

You’re welcome, and I know exacly what you mean. Been there, done that.
Silk