0

Hi,

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

3
Contributors
6
Replies
11
Views
6 Years
Discussion Span
Last Post by puvi
0

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

<?php
ini_set("sendmail_from","Email ID")
?>
0

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??

0

Hey,

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

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.