edwardw Posted August 4, 2011 Share Posted August 4, 2011 Hi all I have recently moved a php application my company uses to a different server (it worked fine on the previous one) I have configured the new linux machine from scratch.. Eventually getting PostgreSQL to work, the only problem i now have is the following Fatal error: Call to undefined function: mail() in /usr/local/apache/htdocs/classes/***.inc on line 1446 Seems to me like for what ever reason the mail/sendmail function has not come installed with PHP... Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/ Share on other sites More sharing options...
trq Posted August 4, 2011 Share Posted August 4, 2011 mail() is built in and cannot (without hacking the source) be removed. Post some code a few lines before and after line 1446. Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251840 Share on other sites More sharing options...
edwardw Posted August 4, 2011 Author Share Posted August 4, 2011 // EMAILING FUNCTION function eMail($recipient, $subject, $message) { $headers = "MIME-Version: 1.0\r\n"; $headers .= "From: NAME <address>\r\n"; $headers .= "Reply-To: NAME <address>\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $headers .= "X-Mailer: PHP / " . phpversion() . "\r\n"; $From = "address"; //echo "$recipient<br> $subject<br> $message<br>$headers"; exit; **** if (mail($recipient, $subject, $message, $headers)) { $a = 1; /* mail('address', $subject, $message, $headers); mail('address', $subject, $message, $headers); mail('address', $subject, $message, $headers); mail('address', $subject, $message, $headers); */ } } /* The line with **** is 1446. What i cant understand is, the code works fine on the current live machine. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251842 Share on other sites More sharing options...
trq Posted August 4, 2011 Share Posted August 4, 2011 How exactly did you install php? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251844 Share on other sites More sharing options...
edwardw Posted August 4, 2011 Author Share Posted August 4, 2011 How exactly did you install php? This is where i had a slight issue... Im running CentOS5... for what ever reason it will not run on php5, so i had to install it manually from some RPMs i found on the internet.. Could this be the reason? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251851 Share on other sites More sharing options...
trq Posted August 4, 2011 Share Posted August 4, 2011 It should definitely exist, I should imagine it would actually be a fair amount of work to remove. Check your php.ini to see that it's not disabled. Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251859 Share on other sites More sharing options...
edwardw Posted August 4, 2011 Author Share Posted August 4, 2011 It should definitely exist, I should imagine it would actually be a fair amount of work to remove. Check your php.ini to see that it's not disabled. Which settings in PHP ini would it be? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251869 Share on other sites More sharing options...
trq Posted August 4, 2011 Share Posted August 4, 2011 disabled_functions Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251873 Share on other sites More sharing options...
edwardw Posted August 4, 2011 Author Share Posted August 4, 2011 disabled_functions I dont have a setting called that in my php.ini! Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251905 Share on other sites More sharing options...
PFMaBiSmAd Posted August 4, 2011 Share Posted August 4, 2011 Does the output from a phpinfo(); statement contain any reference to 'mail' (search on the page using your browser's find function.) What exact problem did you originally have when trying to build/install php5? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251910 Share on other sites More sharing options...
edwardw Posted August 4, 2011 Author Share Posted August 4, 2011 Does the output from a phpinfo(); statement contain any reference to 'mail' (search on the page using your browser's find function.) What exact problem did you originally have when trying to build/install php5? The only mentions of mail are sendmail_from no value no value sendmail_path /usr/sbin/sendmail -t /usr/sbin/sendmail -t I dont think the code worked under php5, although im not sure if i coppied the php.ini off the old server ( just tried this on php4 and it doesnt work either) Im thinking if i cant get this to work, either installing php5, or i should be able to change the code from mail() to PEAR mail shouldnt i? Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251912 Share on other sites More sharing options...
PFMaBiSmAd Posted August 4, 2011 Share Posted August 4, 2011 If you are getting the same error message (undefined function: mail()) on different systems, it is likely that your source file is corrupted and either has some non-printing characters or some non ASCII encoded characters as part of the 'mail' name. I would delete and retype the 'mail' name along with a few characters before and after that in the source code. Quote Link to comment https://forums.phpfreaks.com/topic/243818-call-to-undefined-function-mail/#findComment-1251927 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.