Jump to content

Call to undefined function: mail()


Recommended Posts

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?

Link to comment
Share on other sites

// 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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.