Re: Fatal error: Class 'Mail' not found



On Mar 28, 4:32 pm, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@xxxxxxxxxxxxxxxx> wrote:
youu...@xxxxxxxxx schreef:





<?php
require_once "Mail.php";

$from = "Sandra Sender <technical@addplus>";
$to = "Ramona Recipient <techni...@xxxxxxxxxxx>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.addplus.biz";
$username = "techni...@xxxxxxxxxxx";
$password = "aptech";

$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 downloaded the code above from internet and i'd tried it in my
computer. However, i get the error message "Fatal error: Class 'Mail'
not found in C:\AppServ\www\seeyouu\mail.php on line 16".
Can anyone help me to solve this problem? i'm new to php, i totally
don't know what happen with this.
Thank you very much

Erm, if you are totally new to PHP, why do you download scripts from the
net and try to use them?
Sounds to me like: "My moonrocket won't fly! Please help, I am totally
new to rocketscience!"
Wouldn't it make more sense to learn some PHP basics first?

Anyway, you error means what it says: You are using a class in your code
that doesn't exist in your script.

Also, what is line 16? Is that the line that starts with:
$smtp = Mail::factory('smtp', ??

You started your script with:
require_once "Mail.php";

That require_once() means that your script will halt and produce a Fatal
error if it cannot find Mail.php. So you did offer Mail.php at least.

The class you are using is from the PEAR packages, I expect you didn't
use PEAR right.
You can find more information here:http://pear.php.net/
but it might be hard to understand if you are totally new to PHP.
Sorry. :-/

Regards,
Erwin Moller- Hide quoted text -

- Show quoted text -

thank you
.



Relevant Pages

  • Re: Unable to send mail ***caution Newbie**
    ... I get an error message "Fatal error: ... I have initializedPhpini file with Smtp address, ... Now in the below mentioned script there are fourmail.phpfiles here, ...
    (comp.lang.php)
  • Re: Form - Email question for NEWB
    ... SMTP localhost localhost ... I have been trying several php form scripts that send an email to me ... email is in the php script. ...
    (comp.lang.php)
  • Re: What is the need for @ symbol in php script
    ... The '@' just suppresses error messages, which is never a good idea (it hides potential problems). ... Such as cases where you don't want a fatal error to stop your application from working, just as long as you trap the error. ... (Can't remember any relevant function at this moment, but I'm pretty I've seen (native PHP) ... All this does is stop the message from being displayed - so the script terminates with no error message. ...
    (comp.lang.php)
  • Re: Unable to send mail ***caution Newbie**
    ... Try the PEAR class Net_DNS. ... I have initialized Php ini file with Smtp address, ... Now in the below mentioned script there are four mail.php files here, ...
    (comp.lang.php)
  • Unable to send mail ***caution Newbie**
    ... I get an error message "Fatal error: ... I have initialized Php ini file with Smtp address, ... Now in the below mentioned script there are four mail.php files here, ...
    (comp.lang.php)