Re: PHP cannot use a provided class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx';
> 
>     $to = $sendto;
>     $replyto = 'moe.james@xxxxxxxxxxxxxx';
>     $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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux