1. Go to this page and download the library: Download opscale-co/nova-mailbox 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/ */
opscale-co / nova-mailbox example snippets
// in app/Providers/NovaServiceProvider.php
public function tools()
{
return [
new \Opscale\NovaMailbox\Tool(),
];
}
return [
// Storage path for emails and attachments (relative to disk)
'path' => env('MAILBOX_STORAGE_PATH', 'mailbox'),
// Extraction rules: classes implementing the Extractor interface
'extraction_rules' => [
// \App\Extractors\MyExtractor::class,
],
];
use BeyondCode\Mailbox\InboundEmail;
use Opscale\NovaMailbox\Contracts\Extractor;
use Opscale\NovaMailbox\Models\Email;
use Opscale\NovaMailbox\Models\Extraction;
class MyExtractor implements Extractor
{
public function matches(InboundEmail $email): bool
{
// Return true if this rule should process the email
}
public function process(InboundEmail $email): ?Extraction
{
// Extract data and create an Extraction record
// Use $email->id() to find the stored Email record:
$record = Email::where('message_id', $email->id())->firstOrFail();
return Extraction::create([
'email_id' => $record->id,
'template_id' => $template->id,
'status' => ExtractionStatus::Completed,
'data' => [
// extracted fields
],
]);
}
}