1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00
invoiceninja/app/Helpers/Mail/GmailTransportConfig.php

48 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Helpers\Mail;
use App\Libraries\MultiDB;
2019-12-04 06:26:07 +01:00
use App\Mail\SupportMessageSent;
use App\Models\User;
use App\Providers\MailServiceProvider;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
2019-12-04 06:26:07 +01:00
use Laravel\Socialite\Facades\Socialite;
/**
* GmailTransportConfig.
*/
class GmailTransportConfig
{
public function test()
{
/********************* We may need to fetch a new token on behalf of the client ******************************/
$query = [
'email' => 'david@invoiceninja.com',
];
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();
Config::set('mail.driver', 'gmail');
Config::set('services.gmail.token', $user->oauth_user_token);
(new MailServiceProvider(app()))->register();
Mail::to('david@romulus.com.au')
->send(new SupportMessageSent('a cool message'));
}
}