PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Sun Nov 02, 2003 12:10 pm
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!
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Sun Nov 02, 2003 1:09 pm
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'];
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Sun Nov 02, 2003 1:29 pm
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.
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Sun Nov 02, 2003 6:33 pm
Nope. It works, but I don't get an e-mail.
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Sun Nov 02, 2003 7:25 pm
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";
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Sun Nov 02, 2003 7:37 pm
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. >< >< >< ><
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Sun Nov 02, 2003 9:00 pm
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.
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Mon Nov 03, 2003 5:42 am
Ok, I made that and went to it in a browser, but nope, I don't get an e-mail.
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Mon Nov 03, 2003 9:10 am
Then I suggest you contact your web host and let them know that you can not send any emails from PHP using mail().
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Mon Nov 03, 2003 1:50 pm
maybe you're email service is just crap??
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Mon Nov 03, 2003 3:21 pm
LiLpunkSkateR wrote: maybe you're email service is just crap??
That's a bit harsh
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Mon Nov 03, 2003 4:33 pm
It's my own server.
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Mon Nov 03, 2003 5:09 pm
renaxgade wrote: It's my own server.
Have you got an Email Server set up?
renaxgade
Forum Newbie
Posts: 17 Joined: Wed Oct 29, 2003 4:02 pm
Post
by renaxgade » Mon Nov 03, 2003 5:44 pm
I think the one that came with Redhat (sendmail) but other thatn that, no.
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Mon Nov 03, 2003 7:02 pm
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.