Page 1 of 2

Sendmail error

Posted: Sun Nov 02, 2003 12:10 pm
by renaxgade
I have a form and it POSTS to Mail.php, Mail.php looks like:

Code: Select all

<?php
$to = "**@*.net"
$subject = "icon";
$body = $_POST['name'] + "\n\r" + $_POST['sn']";
$from = "From: Joey<Wesite@LAL.com>\n";
$headers = $from;
mail($to, $subject, $body, $headers);
?>
It just does not want to mail to me. I have of course replaced the stars with my e-mail, its just for security. I have started sendmail in init.d, and it's in php.ini. HELP ME!

Posted: Sun Nov 02, 2003 1:09 pm
by d3ad1ysp0rk

Code: Select all

$body = $_POST['name'] + "\n\r" + $_POST['sn']";
you have an extra quote

make it

Code: Select all

$body = $_POST['name'] + "\n\r" + $_POST['sn'];

Posted: Sun Nov 02, 2003 1:29 pm
by Gen-ik
LiLpunkSkateR wrote: make it

Code: Select all

$body = $_POST['name'] + "\n\r" + $_POST['sn'];


Shouldn't it be....

Code: Select all

$body = $_POST['name'] . "\n\r" . $_POST['sn'];
...it's PHP not JavaScript.

Posted: Sun Nov 02, 2003 6:33 pm
by renaxgade
Nope. It works, but I don't get an e-mail.

Posted: Sun Nov 02, 2003 7:25 pm
by Gen-ik
You also need to escape the newline character.

Code: Select all

// THIS IS WRONG
$from = "From: Joey<Wesite@LAL.com>n"; 

// THIS IS CORRECT
from = "From: Joey<Wesite@LAL.com>\n"; 

// THIS IS BETTER
from = "From: Joey<Wesite@LAL.com>\r\n";

Posted: Sun Nov 02, 2003 7:37 pm
by renaxgade
Still get no e-mail. It doesnt really matter of the address its from right? Maybe my php.ini isnt configured right, or my sendmail is just not right. >< >< >< ><

Posted: Sun Nov 02, 2003 9:00 pm
by Gen-ik
Try a very basic email to see if it's a coding problem or a server/settings problem.

Code: Select all

<?

mail("you@somewhere.xxx", "Test Email", "This is a test.", "From:anyone@anywhere.xx");

?>
Obviously change the you@somewhere.xxx to your email address.... don't worry about the From: for now as you can put any email in there valid or not.

Posted: Mon Nov 03, 2003 5:42 am
by renaxgade
Ok, I made that and went to it in a browser, but nope, I don't get an e-mail.

Posted: Mon Nov 03, 2003 9:10 am
by Gen-ik
Then I suggest you contact your web host and let them know that you can not send any emails from PHP using mail().

Posted: Mon Nov 03, 2003 1:50 pm
by d3ad1ysp0rk
maybe you're email service is just crap??

Posted: Mon Nov 03, 2003 3:21 pm
by twigletmac
LiLpunkSkateR wrote:maybe you're email service is just crap??
That's a bit harsh 8O :wink:

Posted: Mon Nov 03, 2003 4:33 pm
by renaxgade
It's my own server.

Posted: Mon Nov 03, 2003 5:09 pm
by Gen-ik
renaxgade wrote:It's my own server.
Have you got an Email Server set up?

Posted: Mon Nov 03, 2003 5:44 pm
by renaxgade
I think the one that came with Redhat (sendmail) but other thatn that, no.

Posted: Mon Nov 03, 2003 7:02 pm
by Gen-ik
I don't know Redhat so my help ends here. It definatly sounds like an Email Server configuration problem though so that's where you will need to start looking.