0
votes

I've been trying to get PHPMailer to work for about a week now. At first I did not use SMTP, but I had to change this because of PHP permissions.

Since the e-mail address that's being used seems to be bought through Gmail (it has a different domain, not @gmail.com) I figured it was best to use the Gmail SMTP service of Google. (Which is explained here https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2)

Because of inexperience and a lack of any way to approach my host via commandline, I got all the necessary packages with a locally installed version of composer and copied all dependencies through FTP to my host. My current folder structure is now like this:

/phpmailer
/phpmailer/extras/
/phpmailer/language/
/phpmailer/vendor/
/phpmailer/vendor/composer/
/phpmailer/vendor/eloquent/
/phpmailer/vendor/guzzlehttp/
/phpmailer/vendor/league/
/phpmailer/vendor/paragonie/
/phpmailer/vendor/phpmailer/
/phpmailer/vendor/psr/
/phpmailer/vendor/autoload.php

However, I keep getting the following error:

Fatal error: Class 'League\OAuth2\Client\Provider\Google' not found in /domain/phpmailer/class.phpmaileroauthgoogle.php on line 55

It looks as if it is missing an include or require somewhere, so I tried adding require('vendor/autoload.php'); in my PHP that handles the form that should start the mailing process, but it does not seem to solve anything. And I also do not expect that adding something like that to files in /phpmailer/ should be necessary.

The rest of the log that I get returned looks like this:

2017-03-26 10:23:52 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP e16sm10314377wra.62 - gsmtp 2017-03-26 10:23:52 CLIENT -> SERVER: EHLO www.domain.com 2017-03-26 10:23:53 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a0b:7280:100:0:447:56ff:fe00:207b] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-03-26 10:23:53 CLIENT -> SERVER: STARTTLS 2017-03-26 10:23:53 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-03-26 10:23:53 CLIENT -> SERVER: EHLO www.domain.com 2017-03-26 10:23:53 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a0b:7280:100:0:447:56ff:fe00:207b] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8

It does not really seem to be a problem with authentication.

This is what's in composer.json:

{
"name": "phpmailer/phpmailer",
"type": "library",
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"authors": [
    {
        "name": "Marcus Bointon",
        "email": "[email protected]"
    },
    {
        "name": "Jim Jagielski",
        "email": "[email protected]"
    },
    {
        "name": "Andy Prevost",
        "email": "[email protected]"
    },
    {
        "name": "Brent R. Matzelle"
    }
],
"require": {
    "php": ">=5.0.0",
    "phpmailer/phpmailer": "^5.2",
    "league/oauth2-client": "^2.2",
    "league/oauth2-google": "^2.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"
}

Am I missing something here?

1
Can you post the content of your composer json file? since it controls which modules and classes are added to your php's classpath.emeraldjava
Hi, I added the contents of composer.json in my initial postGeirrBenayahu
I think your issue is related to this post: stackoverflow.com/a/69487739/5810125Nsamba Isaac

1 Answers

0
votes

(Edit: Apologies, I didn't see that you'd already added the dependency to your composer.json)

That extra dependency should really be in your own apps's composer.json (not PHPMailer's), because you should never need to edit packages loaded via composer. You probably just need to run composer update (not just composer install). Otherwise it will only load the packages in the most recent composer.lock file, not extra ones that you have added.