Page 1 of 1
Mail Script not sending mail...
Posted: Thu Jan 22, 2004 4:53 am
by phpnewbie1985
Ok I have made a test page where it sends a simple message to my address the following code is...
Code: Select all
<?
$to = "my-mail@btopenworld.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$_POST['frmail']."\r\n";
$mail = @mail($to,$_POST['subj'],$_POST['msg'],$headers);
// The "@" sign before the mail() call suppresses printing of errors
// that may occur. The test below will check for errors instead:
if(!$mail){
echo "Email not sent! Please try later...";
}else{
echo "Mail sent successfully!";
}
?>
The problem is when i click the send button it says "e-mail not sent! blah blah blah," can anyone tell me why this is happening according to my server it is all set up.
http://www.foci.co.uk/phpcheck.php
Any help would be gratfully received
Chris
Posted: Thu Jan 22, 2004 9:19 am
by kendall
Chris,
Hmmmm im not sure but have you tried it without the "headers"? i think you may have a problem with the headers...i dont tink its done correctly....i have posted some mail scripts search for my name under "mail()" and see what you come up with maybe it may prove some help
Kendall
Posted: Thu Jan 22, 2004 9:27 am
by malcolmboston
as is the common problem with sendmail.......
........check your configuration in php.ini
this is nearly always the problem
hope this helps
Posted: Thu Jan 22, 2004 9:37 am
by phpnewbie1985
how do i check that? :S sorry if i sound dumb
Posted: Thu Jan 22, 2004 9:41 am
by malcolmboston
on windows c:windows-php.ini
on linux - cant remember
theres some configuration options for mail
have a look at that, it will not owkr if you havent already configured it
Posted: Thu Jan 22, 2004 9:43 am
by phpnewbie1985
i cant check that though as this is not my server i am paying for the space...
Posted: Thu Jan 22, 2004 9:45 am
by malcolmboston
create a page and do this
<?php
php_info()
?>
that should tell you config options for PHP
you will have to get your host to set up mail then ( at a price probably)
Posted: Thu Jan 22, 2004 9:49 am
by phpnewbie1985
I have already got that page up...
i dont know what im meant to be looking for
http://www.foci.co.uk/phpcheck.php is the page i made with that script on have a look...
Posted: Thu Jan 22, 2004 9:51 am
by malcolmboston
change them to whatever applies to you
Posted: Thu Jan 22, 2004 9:52 am
by phpnewbie1985
and to do tat i have to ring my host?
Posted: Thu Jan 22, 2004 9:54 am
by malcolmboston
more than likely, i havent bothered with send-mail so i couldnt tell you, however i believe you have to be able to have direct access to your PHP.ini to use it
Posted: Thu Jan 22, 2004 9:55 am
by phpnewbie1985
ah ok cheers, you have been really helpful!
Chris
Posted: Thu Jan 22, 2004 10:03 am
by redmonkey
The sendmail_path only applies to *nix machines. The phpinfo() in this case indicates it is running on a windows box therefore the sendmail_path should not have a value.
The sendmail_from value is the default value to use if from is not specified within your mail function call.
Assuming the SMTP address is valid it looks like mail is setup correctly.
Posted: Thu Jan 22, 2004 10:10 am
by malcolmboston
i was just trying to give ideas about what is possibly wrong