1. Go to this page and download the library: Download mail-map/laramail-map library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// app/MailMaps/GithubMailMap.php
namespace App\MailMaps;
use LaraMailMap\LaraMailMap;
class GithubMailMap extends LaraMailMap
{
}
// app/Models/Imap/GithubEmail.php
namespace App\Models\Imap;
use MailMap\Mail;
class GithubEmail extends Mail
{
// Find the github user's username who sent the message.
// 'Unknown' if it wasn't found
public function findSenderUser()
{
return $this->header('X-GitHub-Sender', 'Unknown');
}
}
// app/Providers/MailMapProvider.php
namespace App\Providers;
use App\MailMaps\GithubMailMap;
use App\Models\Imap\GithubEmail;
use Illuminate\Support\ServiceProvider;
use MailMap\MailFactory;
class MailMapProvider extends ServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton(GithubMailMap::class, function () {
$config = config('mailmap'); // connection information
$mailbox = config('mailmap.mailboxes.github'); // name of the mailbox for this MailMap
$factory = new MailFactory(GithubEmail::class); // This will generate our GithubEmail "models"
return new GithubMailMap($config, $mailbox, $factory);
});
}
}