Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:03:54+00:00 2026-06-06T09:03:54+00:00

I’m trying to use require_once to call Mail.php but when I create a new

  • 0

I’m trying to use require_once to call Mail.php but when I create a new instance for that class and start using it I get a message that says

Fatal error: Class 'Mail' not found in D:\xampp\htdocs\proj\Mailing\mymail.php on line xx

The resumed code goes like this

<?php
     require_once 'Autoload.php';

     $smtp = Mail::factory('smtp',
          array ('host' => $host,
          'port' => $port,
          'auth' => true,
          'username' => $username,
          'password' => $password));
?>

or also

<?php
     require_once 'Mail.php';

     $mail = new Mail();
?>

Why do I get that message?
I already set the include path to “.;D:\xampp\php\pear”

I edited my script and required the autoload script, which works just fine, cause it prints no error, but I still get the same message like Mail doesn’t work (I edited the script above), autoload is in the same directory where my main script is.

I made a new file and called it with the full path, and then the output was

Warning: require_once(D:\xampp\php\PEAR) [function.require-once]: failed to open stream: Permission denied in D:\xampp\htdocs\proj\Mailing\pMail.php on line 2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:03:55+00:00Added an answer on June 6, 2026 at 9:03 am

    When you are loading a class you don’t need to require your php file if you use autoloading.

    Example:

    Class Autoload {
       private $rootDirectory;
       private $paths = array(
           "system/core",
           "system/obj",
           "system/data"
       );
    
       public function __construct() {
           $this->RootDirectory = dirname(getcwd()); // Whatever is your root
           $this->activateAutoload("autoloadClassesFromSystemFolder");
       }
    
       private function autoloadClassesFromSystemFolder($i) {
           foreach ($this->paths as $path) {
               // Please keep in mind that a class name has to be unique. 
               if (is_file($this->RootDirectory .'/'. $path .'/'. $i . ".php")) {
                   include $this->RootDirectory .'/'. $path .'/'. $i . ".php";
                   break;
               }
           }
       }
    
       public function activateAutoload($functionName) {
           spl_autoload_register(array($this, $functionName));
       }
    }
    

    The only thing you need to do to load this in php is:

    require "path/to/autoload.php";
    $autoload = new Autoload();
    

    After that you can use as many classes as you want without having to worry about class file includements.

    $mail = new Mail();
    

    More info: http://nl.php.net/autoload

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.