Page 1 of 1

sendmail newbie question

Posted: Wed Jan 26, 2005 10:51 pm
by LittleBill
i finally installed php support for my apache server with help from http://www.thesitewizard.com/

now im trying to write his code for a sendmail form but having issues

i have 2 files one is index.php
the second is sendmail.php

the code i have for index. php is
<html>
<title>Hello</title>
<body>
<form method="post" action="sendmail.php">
Email: <input name="email" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
</body>
</html>

the code for sendmail.php is
<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( "littlebill@littlebill.shacknet.nu", "Feedback Form Results",
$message, "From: $email" );
header( "Location: http://www.yahoo.com" );
?>

this is the error i get
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in c:\documents and settings\littlebill\desktop\webpage\sendmail.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at c:\documents and settings\littlebill\desktop\webpage\sendmail.php:6) in c:\documents and settings\littlebill\desktop\webpage\sendmail.php on line 7

this is what i have load in the php.ini on the apache server

[mail function]
; For Win32 only.
SMTP = smtp.littlebill.shacknet.nu
smtp_port = 25

; For Win32 only.
;sendmail_from = LittleBill@littlebill.shacknet.nu

this is apache on a xp computer

now am i have a syntax error or is this a mail server issue, as my users have to authenticate to send, the mail server is not an open relay, but i switched it to open relay with no luck, any help would be greatly appreicated

you can find the above program at

http://littlebill.shacknet.nu:81/index.php

again i would really appreciate it

Posted: Wed Jan 26, 2005 10:55 pm
by feyd
your header warning can be fixed by reading through and following the tutorial: Warning: cannot add header information

as for everything else, I'm not sure.

Posted: Wed Jan 26, 2005 11:11 pm
by LittleBill
thanks for the help on the header, but is the sendmail aspect of something you guyz don't normally see? i hope this isn't cryptic im trying basic stuff here

Posted: Wed Jan 26, 2005 11:13 pm
by feyd
we've seen it, I just haven't dealt with it personally. You may want to search the forums, if you already haven't.

Posted: Wed Jan 26, 2005 11:29 pm
by LittleBill
i have fixed the problem by adding

ini_set('sendmail_from', 'littlebill@littlebill.shacknet.nu');

before my mail command

<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;


ini_set('sendmail_from', 'littlebill@littlebill.shacknet.nu');
mail( "littlebill@littlebill.shacknet.nu", "Feedback Form Results",
$message, "From: $email" );
?>

it was said this was need for a windows version of php which i am running with apache, it was also said i could add this in my php.ini file, could someone tell me where exactly i could add that so i don't have to keep adding that init line in all my coding

Posted: Wed Jan 26, 2005 11:31 pm
by feyd
you have that line, commented out, in your php.ini section you posted earlier. remove the semicolon ; before that line.

make sure to restart the server ;)

Posted: Wed Jan 26, 2005 11:35 pm
by LittleBill
lol i feel extremly dumb, this is kinda of y i hate programming, some one give me a GUI please... my problem is fixed, just have to figure out the header thing now

Posted: Thu Jan 27, 2005 12:22 am
by shiznatix
i dunno anything bout headers but when i get a header error i put (u gotta put this as THE FIST THING no matter what in the code, the 1st line.)

їcode]
ob_start();
ї/code]

this has fixed evey header error iver ever gotten although ppl are going to look at it and be like that kid sux but use it any it will work, remember before the <html> before the css it has to be the 1st line in the file no matter what.

Posted: Thu Jan 27, 2005 12:23 am
by feyd
ob_start = band-aid ;)

Posted: Thu Jan 27, 2005 12:29 am
by LittleBill
lol, im kinda of losing it i tried a ton of different searches and still don't know what the hell im looking for

let me ask a couple newbiew questions one is what the hell does the header do?

also after they submit the form how do i get them to another page instead of it just going blank after the submit

Posted: Thu Jan 27, 2005 12:35 am
by feyd
http://php.net/header

the header is textual data sent to the browser that it doesn't normally show you. It's used for cookies, and other agent settings and server information. If a header call happens after content has started streaming out, the headers have already been sent, and therefore the header call will do nothing.

header() is used most often to redirect the client to a new location.