2019-11-27 10:47:59 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-11-27 10:47:59 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-11-27 10:47:59 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Helpers\Mail;
|
|
|
|
|
2019-12-04 05:52:04 +01:00
|
|
|
use App\Libraries\MultiDB;
|
2019-12-04 06:26:07 +01:00
|
|
|
use App\Mail\SupportMessageSent;
|
2019-11-27 10:47:59 +01:00
|
|
|
use App\Models\User;
|
2019-12-04 05:52:04 +01:00
|
|
|
use App\Providers\MailServiceProvider;
|
|
|
|
use Illuminate\Support\Facades\Config;
|
2019-11-27 10:47:59 +01:00
|
|
|
use Illuminate\Support\Facades\Mail;
|
2019-12-04 06:26:07 +01:00
|
|
|
use Laravel\Socialite\Facades\Socialite;
|
2019-11-27 10:47:59 +01:00
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* GmailTransportConfig.
|
2019-11-27 10:47:59 +01:00
|
|
|
*/
|
|
|
|
class GmailTransportConfig
|
|
|
|
{
|
2019-12-04 05:52:04 +01:00
|
|
|
public function test()
|
2019-11-27 10:47:59 +01:00
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
/********************* We may need to fetch a new token on behalf of the client ******************************/
|
|
|
|
$query = [
|
|
|
|
'email' => 'david@invoiceninja.com',
|
|
|
|
];
|
2019-11-27 10:47:59 +01:00
|
|
|
|
2019-12-04 06:26:07 +01:00
|
|
|
$user = MultiDB::hasUser($query);
|
|
|
|
// $oauth_user = Socialite::driver('google')->stateless()->userFromToken($user->oauth_user_token);
|
|
|
|
|
|
|
|
// $user->oauth_user_token = $oauth_user->refreshToken;
|
|
|
|
// $user->save();
|
2019-12-04 03:27:28 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
Config::set('mail.driver', 'gmail');
|
|
|
|
Config::set('services.gmail.token', $user->oauth_user_token);
|
|
|
|
(new MailServiceProvider(app()))->register();
|
2019-12-04 03:27:28 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
Mail::to('david@romulus.com.au')
|
|
|
|
->send(new SupportMessageSent('a cool message'));
|
2019-11-27 10:47:59 +01:00
|
|
|
}
|
|
|
|
}
|