我做的第一件事是
在我的 linux 系统上安装了 composer
su 到目录用户
在 public_html PHPMailer-5_2_23 中创建了一个目录
改到那个目录
将 php 邮件程序上传到该目录
然后在github上的phpmailer提供的composer.json上运行composer update: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"
}
完成后,我运行了 composer 命令“需要联盟/oauth2-google”,如下所述:
https://packagist.org/packages/league/oauth2-google
我添加了用户设置以获取 get_oauth_token.php 以在我的浏览器上显示 token ,但我得到
PHP fatal error :
Class 'League\OAuth2\Client\Provider\Google' not found in {my directories }
所以我假设有些东西没有看到类(class),但我几乎找不到任何关于它的信息
有什么建议或方向吗?
最佳答案
phpMailer 是一个库包;它通常用作较大应用程序的一部分。在这种情况下,它应该是使用 Composer 安装 phpMailer 及其依赖项的主应用程序。您通常不希望手动将 phpMailer 上传到您的应用程序,然后为此使用 Composer,这听起来像是您正在做的。
所以这是你应该做的。
composer require phpmailer/phpmailer
composer require league/oauth2-google
(你已经做了第二个,所以可能不需要,但你做的时候没有说你在哪个文件夹中)
require_once 'vendor/autoload.php';
. 关于php mailer 5.2.23 通过composer安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43738759/