Jump to content

Smtp E-mail Via Pear


uaintgotthisid
 Share

Recommended Posts

Hi all,I've changed my server over to Linux, and it has PEAR Installed.However my contact form still doesn't work.My dummy mail pageSee the link above for the error (Fatal error: Undefined class name 'mail' in /home/ufmcom/public_html/about-mail.php on line 16)below is the code which I nicked from somewhere after a link I found on this forum. PEAR documentation says that if you receive this error it's probably because of the second line:require_once "about-mail.php" which it says I may have typed as require_once "mail/about-mail.php". You can see I have not done this but I am wondering if perhaps my code is looking in the wrong place for the mail function. Does anyone more knowledgeable than I know if this is correct? I hate just guessing as I don't really have enough knowledge to know if I'm right or wrong.

<?phprequire_once "about-mail.php";$from = "Sandra Sender <monkey.parts@sillyme.com>";$to = "Ramona Recipient <example@example.com>";$subject = "Hi!";$body = "Hi,\n\nHow are you?";$host = "mail.example.com";$username = "******";$password = "******";$headers = array ('From' => $from,  'To' => $to,  'Subject' => $subject);$smtp = Mail::factory('smtp',  array ('host' => $host,	'auth' => true,	'username' => $username,	'password' => $password));$mail = $smtp->send($to, $headers, $body);if (PEAR::isError($mail)) {  echo("<p>" . $mail->getMessage() . "</p>"); } else {  echo("<p>Message successfully sent!</p>"); }?>

Link to comment
Share on other sites

  • 1 month later...

The problem is that PHP can't find the about-mail.php file. When you use a require or include statement, PHP checks in the locations defined in the include_path option first, then in the current working directory. This is from the manual:

Files for including are first looked for in each include_path entry relative to the current working directory, and then in the directory of current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/libraries/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in the current working directory.
You can check what the include_path is, and other settings, by using phpinfo. So you need to either copy the about-mail.php file into one of the include paths, or put it in the working directory, or change the include path to include the location where the file is.You might also not even have that Pear module installed, which would mean you would have to install it first.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...