Re: PHP cannot use a provided class
| From: | Christoph M. Becker | Date: | Tue, 20 Mar 2018 22:14:49 +0000 |
| Subject: | Re: PHP cannot use a provided class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326395@lists.php.net to get a copy of this message | ||
On 20.03.2018 at 21:37, James Moe wrote:
> 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
>
> //Import the PHPMailer class into the global namespace
> // use PHPMailer\PHPMailer\PHPMailer;
Either properly import the class:
use PHPMailer\PHPMailer;
> $from = 'sma.info@sohnen-moe.com';
>
> $to = $sendto;
> $replyto = 'moe.james@sohnen-moe.com';
> $cc = '';
> $bcc = '';
>
> // use PHPMailer;
>
> $mail = new PHPMailer();
Or use the fully qualified class name:
$mail = new \PHPMailer\PHPMailer;
See also the chapter about namespaces in the PHP manual:
<http://www.php.net/manual/en/language.namespaces.php>
--
Christoph M. Becker