Page 1 of 1
mail() yes again, but different
Posted: Tue Nov 12, 2002 12:49 pm
by MedaXis
hi everyone
I recently tried the mail() function in php, but I got this error:
Fatal error: Call to undefined function: mail() in mail.php on line 2
I used this piece of code:
Code: Select all
<?php
mail("me@myprovider.com","testtie","ooh nooo","From: Hi");
?>
why doesn't it work
//I tried the forum search, did find some mail() topics, but none of contain info on the error I got.
Steve
Posted: Tue Nov 12, 2002 1:27 pm
by twigletmac
It's telling you that the mail() function does not exist in your build of PHP, which version of PHP are you using and on what OS are you using it?
Mac
Posted: Wed Nov 13, 2002 5:33 am
by MedaXis
OS = windows
PHP4
Steve
Posted: Wed Nov 13, 2002 5:40 am
by twigletmac
Which version of PHP 4 and which version of Windows? How did you install PHP - using the self-installer or manually?
Mac
Posted: Wed Nov 13, 2002 8:36 am
by MedaXis
okay, I'm sorry I didn't give much info
on the server: php 4.2.3
I'm using win xp
Steve
Posted: Wed Nov 13, 2002 8:56 am
by twigletmac
Have you tried reinstalling PHP?
Mac
Posted: Wed Nov 13, 2002 10:07 am
by m3mn0n
mail() should be in php. I would do as Mac suggested and reinstall php. OR maybe it is because that content you have in mail()... I use this format for mailing:
Code: Select all
<?php
<?
if($Submit){
$To = "oromian@hotmail.com";
$Subject = trim($Subject);
$Body = trim($msg);
$Name = trim($from);
$Email = trim($fromaddy);
if(mail($To, $Subject, $Body, "From: $Name <$Email>")){
echo "<b>Thanks! $Name,</b></b><br><br>Your Email was sent!";
} else {
echo "<b>Sorry! $Name</b>,<br><br>Your Email was not sent!<br><br>contact me here: oromian@hotmail.com";
}
}
?>
?>
That is a snipplet of my script i use so people can send me feedback, i see in yours there isn't a proper mailing address nor proper from address, could that be it??
Posted: Wed Nov 13, 2002 11:07 am
by MedaXis
thanks guys,
I didn't reinstall php, but I tried my file at an account at lycos
it worked
maybe I should have tried that before posting, sorry
anyway, thanks for the replies!
Steve
I know why...
Posted: Wed Nov 13, 2002 3:56 pm
by evilmonkey
I know why this happenned. I am running Windows XP with PHP 4.1.1.
The problem is Windows doesn't have a mail server, unliess you install it. Therefore, there is no way for a mail function to work. Once you upload it to a linux server (lycose, whatever), it starts working.
Cheers.
Posted: Wed Nov 13, 2002 4:27 pm
by volka
that would give you an mail error like "error: unknown mail host" or similiar
Fatal error: Call to undefined function: mail() in mail.php on line 2
really means php does not know the function at all

Posted: Thu Nov 14, 2002 2:43 am
by twigletmac
You should probably reinstally PHP locally even though you have a remote host because your version could have other bugs aside from a missing mail() function.
Mac
Posted: Thu Nov 14, 2002 9:32 am
by Heavy
Right now, I don't have a php.ini at hand so correct me if I'm wrong...
Isn't mail some kind of extension that has to be enabled in php.ini, when using Windows?
That error message seems like PHP requires a linked library that is not linked.
Posted: Fri Nov 15, 2002 6:27 am
by twigletmac
The mail() function should be built into PHP as standard - you have to tell it where to send mail in the php.ini but the actual function should just be available by default.
Mac