PHP cannot use a provided class
| From: | James Moe | Date: | Tue, 20 Mar 2018 20:37:22 +0000 |
| Subject: | PHP cannot use a provided class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-326394@lists.php.net to get a copy of this message | ||
Hello,
php v5.6.34
I am working on a very simple PHPMailer; all it has to do is send an
email. I am using the latest version from the Github repository, v6.0.3.
Running the program produces this:
Fatal error: Class 'PHPMailer' not found in
/home/sohne/web/php/common/php-test-email.php on line 44
The program obviously loads the class files; there is no error there.
Yet trying to create a new instance fails.
What am I missing?
----[ The start of the program ]----
define('PHP_COMMON', '/home/sohne/web/php/common/');
require(PHP_COMMON . 'phpmailer-603/PHPMailer.php');
require(PHP_COMMON . 'phpmailer-603/Exception.php');
require(PHP_COMMON . 'phpmailer-603/SMTP.php');
//Import the PHPMailer class into the global namespace
// use PHPMailer\PHPMailer\PHPMailer;
$from = 'sma.info@sohnen-moe.com';
$to = $sendto;
$replyto = 'moe.james@sohnen-moe.com';
$cc = '';
$bcc = '';
// use PHPMailer;
$mail = new PHPMailer();
**Splat!**
----[ end ]----
This is the head portion of the PHPMailer Class:
namespace PHPMailer\PHPMailer;
class PHPMailer
{
---- the rest of the class ---
}
--
James Moe
jmm-list at sohnen-moe dot com
Think.