PEAR mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

PEAR mail

Post by jmilane »

This is making me crazy.

I know it is because I am missing something basic AGAIN!!!!

I get this error:

Fatal error: Class 'Mail' not found in D:\ULEM WebSite\forms\mail.php on line 17

But I swear, when you look in D:\ULEM WebSite\forms\ there is absolutely mail.php and it was part of the pear distribution.

In fact, I have put mail.php just about everywhere now!

I have even tried using the absolute path.

How do I get this script to find what it needs?!?! It is BASIC!!!!!

Code: Select all

<?php

require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_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>");
 }
?>
I know it is looking to the current directory, so I have tried changing "mail.php" to the absolute path of every single instance of mail.php on this computer.

My head hurts.

I swear, I TRY to figure this stuff out before I ask questions... I really do.

Thanks, and sorry.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You'd probably be better off using Swift Mailer. However, that is irrelevant to the problem you are facing.

You may want to try this:

Code: Select all

set_include_path('/path/to/pear' . PATH_SEPARATOR . get_include_path());
However, I'm not exactly sure what problem you have. Can you tell me the name of the current script file and where it is located?

Edit - Doink!
Last edited by Ambush Commander on Thu Sep 21, 2006 8:43 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

psst, PATH_SEPARATOR.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

That's probably one of the most common typos I make. I knew I should have looked up the constant before I posted... >.>
Post Reply