0

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
  • 1
    if mail() bails, you need to install a MTA (sendail is existentially challenged). Voting to migrate this to serverfault where you'll receive better answers. Commented Mar 11, 2010 at 14:35

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

yeah, I go straight in php learning instead of setting up the webserver, php and mysql.
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.
Hi Don, What do you mean setup in my email client? Do you mean my mail serve which I am using right now?
1

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 ?

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.