i am new to php and i have lots of doubts since i'm learning it on my own, any help/advice/suggestion is very much appreciated. i have gone through many threads, but they dont answer to what i'm seeking. if i missed any thread which answers to the point, please share the link.

here is what im trying to do: to send email on the click of submit button(body of the email is the content of Contact Us form), i'm trying to do this on local machine without any mail server. IS IT POSSIBLE TO SEND EMAIL?. i have this Contact Us form with Name(text box), Email Id(text box), Comments(text area) and 2 buttons: Reset and Submit. The function of the buttons are as follows: on clicking reset, all the fields should go blank and on clicking submit, the contents of the form should be emailed to the website admin. I have got 2 files contactus.php and sendemail.php. In contactus.php, the form tag is as follows:
<form method="post" action="sendemail.php" and onSubmit="return validate(this)">

currently, i get this error
"Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\learn\project1\sendemail.php on line 10
email not sent"
do i need to make any changes in php.ini? or add the header??, but as far as i know, headers is a optional field in mail function.

If we cannot send email from local machine without mail server, then, when this code is uploaded lets say on hostgator.com what changes to i need to make in the php.ini(where in php.ini) and header field in mail function to make this work?

Thanks a lott

You can dynamically specify the from value like this below. Place this code at the top of your file.

ini_set("sendmail_from","Email ID")

hi, thanks for the quick reply, do u mean to say, to place this code at the top of php.ini file, when the code is uploaded on hostagator.com or some server similar??


Nooo.. Place this code at the top of php file, where you are calling the mail function. Not at php.ini

hey thanks for the clearing my doubts.
so no need to make changes in the php.ini isnt it?

@ manuz, thank u.
@ chrishea, thank u too, the blog answered all my querries. i made a point to bookmark the blog for future reference :)