tags:

views:

72

answers:

2

Hi,

I am a PHP newbie coder. Currently I am studying the mail function of PHP but the function always give me error such as Server error. I don't know if I have to install a software or configure the server first. By the way, I use Phpdev for my development environment.

if(mail("[email protected]", "Hi","This is a test"))
{
   echo "Success";
}
else
{
   echo "Failed";
}

Many thanks.

+1  A: 

is your mail server configured? see the [mail function] section of the php.ini file and configure it if not. specific instructions are in the sample php.ini files included with your distribution and differ depending on whether you're on windows or *nix.

-don

Don Dickinson
phpdev is only for windows.
solomongaby
yeah, I go straight in php learning instead of setting up the webserver, php and mysql.
sasayins
ok .. so you're in windows. you need to set the smtp server settings in the php.ini file. your smtp server is probably whatever you have setup in your email client, so copy that into your php.ini file in the proper place and it should work.
Don Dickinson
Hi Don,What do you mean setup in my email client? Do you mean my mail serve which I am using right now?
sasayins
+1  A: 

from my knowledge phpdev does not have a server mail, so the mail shoul not work. But it should just print out Failed. What do you mean it throws a server error ?

solomongaby
Here is the error:Warning: Server Error in c:\phpdev\www\mail.php on line 3I see, so phpdev does not have a mail server configured. Can I configure phpdev to install the mail server?
sasayins
i assume you have the php tags in that file ?
solomongaby
yeah, the code is inside of the php tag. probably the mail server is not setup.
sasayins