Search code examples
phpcomposer-phpphpmailer

php mailer 5.2.23 Installation via composer


What I did 1st was

installed composer on my linux system

su to directory user

created a directory in public_html PHPMailer-5_2_23

changed to that directory

uploaded php mailer into that directory

then ran composer update on the supplied composer.json from phpmailer on github here: https://github.com/PHPMailer/PHPMailer

{
"name": "phpmailer/phpmailer",
"type": "library",
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"authors": [
    {
        "name": "Marcus Bointon",
        "email": "phpmailer@synchromedia.co.uk"
    },
    {
        "name": "Jim Jagielski",
        "email": "jimjag@gmail.com"
    },
    {
        "name": "Andy Prevost",
        "email": "codeworxtech@users.sourceforge.net"
    },
    {
        "name": "Brent R. Matzelle"
    }
],
"require": {
    "php": ">=5.0.0"
},
"require-dev": {
    "doctrine/annotations": "1.2.*",
    "jms/serializer": "0.16.*",
    "phpdocumentor/phpdocumentor": "2.*",
    "phpunit/phpunit": "4.8.*",
    "symfony/debug": "2.8.*",
    "symfony/filesystem": "2.8.*",
    "symfony/translation": "2.8.*",
    "symfony/yaml": "2.8.*",
    "zendframework/zend-cache": "2.5.1",
    "zendframework/zend-config": "2.5.1",
    "zendframework/zend-eventmanager": "2.5.1",
    "zendframework/zend-filter": "2.5.1",
    "zendframework/zend-i18n": "2.5.1",
    "zendframework/zend-json": "2.5.1",
    "zendframework/zend-math": "2.5.1",
    "zendframework/zend-serializer": "2.5.*",
    "zendframework/zend-servicemanager": "2.5.*",
    "zendframework/zend-stdlib": "2.5.1"
},
"suggest": {
    "league/oauth2-google": "Needed for Google XOAUTH2 authentication"
},
"autoload": {
    "classmap": [
        "class.phpmailer.php",
        "class.phpmaileroauth.php",
        "class.phpmaileroauthgoogle.php",
        "class.smtp.php",
        "class.pop3.php",
        "extras/EasyPeasyICS.php",
        "extras/ntlm_sasl_client.php"
    ]
},
"license": "LGPL-2.1"
}

after that was done I ran composer command "require league/oauth2-google" as stated here: https://packagist.org/packages/league/oauth2-google

I added the user settings to get get_oauth_token.php to display a token on my brower but i get PHP Fatal error:

Class 'League\OAuth2\Client\Provider\Google' not found in {my directories }

SO I am assuming something is not seeing the Class but i cannot find hardly any info on it Any suggestions or direction?


Solution

  • phpMailer is a library package; it would typically be used as part of a larger application. In that case, it should be your main application that uses Composer to install phpMailer and its dependencies. You wouldn't typically want to upload phpMailer manually into your app and then use Composer just for that, which is what it sounds like you're doing.

    So this is what you should do.

    1. Remove the copy of phpMailer that you have already installed.
    2. Go to the root folder of your project, and issue the following commands:

      composer require phpmailer/phpmailer
      composer require league/oauth2-google
      

      (you already did the second one, so it may not be needed, but you didn't say what folder you were in when you did it)

    3. If you weren't already using Composer for your project, make sure that your code always includes the Composer autoload file. So somewhere at the beginning of every page load, you should call require_once 'vendor/autoload.php';.