i have php and apache running in windows. my problem is i get an error when sending emails using the php mail function. how do i get rid of the error

Install a mail server (Mercury for example). Windows does not have a built-in one. Another option is to use a tool like PHPMailer and connect to your GMail account (assuming you have one).

do i need to make any changes to the php.ini file after installing the mail server

have installed Mercury Mail Server and i'm getting a warning:

Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\moonlight\test.php on line 9.
what changes to i need to make, my php code is as follows:

<?php
    ini_set('SMTP','localhost'); 
    ini_set('sendmail_from', 'dougiedj@gmail.com'); 

    $to = 'dinhunzvi@live.com';
    $subject = 'Example subject';
    $body = 'With an example body…'; 

    mail($to, $subject , $body);
?>

Have you tried with line 3? Mercury needs a from address that is local.

changed the sendmail_from variable to dnhunzvi@moonlight.co.zw but i'm now getting this error.

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\moonlight\test.php on line 9

Failed to connect to mailserver at "localhost" port 25

This suggests Mercury is not running.

BTW, I meant to say "without line 3" in my previous post.

are you saying i should remove line 3 from my code?