2017-08-03 1 views
0

問題があります。 私のコードOauth GoogleでPHPMailerを送信できません。

Fatal error: Uncaught Error: Class 'League\OAuth2\Client\Provider\Google' not found in /opt/lampp/htdocs/mailer/PHPMailer/class.phpmaileroauthgoogle.php:54 Stack trace: #0 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmaileroauthgoogle.php(67): PHPMailerOAuthGoogle->getProvider() #1 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmaileroauthgoogle.php(74): PHPMailerOAuthGoogle->getToken() #2 /opt/lampp/htdocs/mailer/PHPMailer/class.smtp.php(470): PHPMailerOAuthGoogle->getOauth64() #3 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmaileroauth.php(174): SMTP->authenticate('', '', 'XOAUTH2', '', '', Object(PHPMailerOAuthGoogle)) #4 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmailer.php(1540): PHPMailerOAuth->smtpConnect(Array) #5 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmailer.php(1335): PHPMailer->smtpSend('Date: Thu, 3 Au...', 'Message\n') #6 /opt/lampp/htdocs/mailer/PHPMailer/class.phpmailer.php(1213): PHPMailer->postSend() #7 /opt/lampp/htdocs/mailer/index.php(27): PHPMailer->send() #8 {main} thrown in /opt/lampp/htdocs/mailer/PHPMailer/class.phpmaileroauthgoogle.php on line 54 

は、私は私のミスは、私はちょうどphpmailerのはOauth2.0とGoogleのSMTPを使用してメールを作成したいのか分からない。このERORは、私はGoogleで検索した

<?php 
require 'PHPMailer/PHPMailerAutoload.php'; 
$userEmail = "[email protected]"; 
$clientId = "xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"; 
$clientSecret = "xxxxxxxx-xxxxxxxxx"; 
$token = "1/xxxxxxxx-xxxxxxxx-5EmWcSmuvnRbJs"; 

$mailer = new PHPMailerOAuth; 
$mailer->isSMTP(); 
$mailer->Host = 'smtp.gmail.com'; 
$mailer->SMTPAuth = true; 
$mailer->AuthType = 'XOAUTH2'; 
$mailer->oauthUserEmail = $userEmail; 
$mailer->oauthClientId = $clientId; 
$mailer->oauthClientSecret = $clientSecret; 
$mailer->oauthRefreshToken = $token; 
$mailer->SMTPSecure = 'tls'; 
$mailer->Port = 587; 

$mailer->setFrom("[email protected]"); 
$mailer->addAddress("[email protected]"); 

$mailer->Subject = "Subject"; 
$mailer->Body = "Message"; 

if (! $mailer->send()) 
    throw new RuntimeException('Mail submission failed! ' . $mailer->ErrorInfo); 

私は

まだ PHPMailer's composer.json file
+0

'composer install'を実行しましたか?また、 'require '../ vendor/autoload.php''はどこにありますか?あなたのためにこれを扱うフレームワークを持っていない限り、それを含める必要があります。 – Trojan404

+0

ええ、私は作曲家のインストールを実行しました –

答えて

0

ルック解決策を見つけていない - それは必要条件ではない、とそのphpmailerののsuppor古いPHPのバージョンでは動作しませんので、それは、提案としてのOAuthクラスを含みtsであるため、デフォルトで有効にすることはできません。

あなた自身のcomposer.jsonファイル(PHPMailerをロードするのと同じファイル)に追加する必要があります。

Gmail OAuth2 tutorial on the PHPMailer wikiにこの旨のコメントを追加しました。

私はここにいますが、これはPHPMailer 5.2を使用して実装しないでくださいが、OAuth2の方がはるかに優れているPHPMailer 6.0に直接アクセスしてください。

+0

okeey私はこれを試します –

+0

ハイ私は再び私の問題で質問がありますhttps://stackoverflow.com/questions/45499897/cant-send-email-phpmailer-6-0-with- oauth-google @シンクロ –

関連する問題