Skip to content

Commit 552cc20

Browse files
committed
feat(emails): implement email outbox
1 parent 2a7c993 commit 552cc20

13 files changed

Lines changed: 639 additions & 39 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('mail_logs', function (Blueprint $table) {
15+
$table->increments('id');
16+
17+
$table->foreignId('site_id')->nullable()->constrained('sites')->onDelete('cascade');
18+
19+
$table->string('from')->nullable();
20+
$table->string('to')->nullable();
21+
$table->string('cc')->nullable();
22+
$table->string('bcc')->nullable();
23+
$table->string('subject');
24+
$table->text('body');
25+
$table->text('headers')->nullable();
26+
$table->longText('attachments')->nullable();
27+
$table->uuid('message_id')->nullable();
28+
$table->string('status')->nullable();
29+
$table->longText('data')->nullable();
30+
$table->timestamp('opened')->nullable();
31+
$table->timestamp('delivered')->nullable();
32+
$table->timestamp('complaint')->nullable();
33+
$table->timestamp('bounced')->nullable();
34+
35+
$table->foreignId('sender_id')->nullable()->constrained('users')->onDelete('set null');
36+
$table->foreignId('recipient_id')->nullable()->constrained('users')->onDelete('set null');
37+
38+
$table->timestamps();
39+
40+
$table->index('message_id');
41+
$table->index('status');
42+
$table->index(['site_id', 'created_at']);
43+
});
44+
}
45+
46+
/**
47+
* Reverse the migrations.
48+
*/
49+
public function down(): void
50+
{
51+
Schema::dropIfExists('mail_logs');
52+
}
53+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('mail_logs', function (Blueprint $table) {
15+
$table->timestamp('sent_at')->nullable()->after('status');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('mail_logs', function (Blueprint $table) {
25+
$table->dropColumn('sent_at');
26+
});
27+
}
28+
};

resources/lang/en/email.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,31 @@
2929
'recipient_email' => 'Recipient email address',
3030
'invalid_cc_email' => 'One or more CC email addresses are invalid.',
3131
'invalid_bcc_email' => 'One or more BCC email addresses are invalid.',
32+
33+
// Mail Log / Outbox
34+
'outbox' => 'Email Outbox',
35+
'outbox_description' => 'View all outgoing emails',
36+
'email_details' => 'Email Details',
37+
'email_body' => 'Email Body',
38+
'metadata' => 'Metadata',
39+
'user_information' => 'User Information',
40+
'headers' => 'Headers',
41+
'from' => 'From',
42+
'to' => 'To',
43+
'sent_at' => 'Sent At',
44+
'message_id' => 'Message ID',
45+
'status' => 'Status',
46+
'sent' => 'Sent',
47+
'sending' => 'Sending',
48+
'failed' => 'Failed',
49+
'sent_today' => 'Sent Today',
50+
'sent_this_week' => 'Sent This Week',
51+
'back_to_outbox' => 'Back to Outbox',
52+
'view_email' => 'View Email',
53+
'no_emails' => 'No emails found',
54+
'email_log' => 'Email Log',
55+
'show_html' => 'Show HTML',
56+
'show_preview' => 'Show Preview',
57+
'email_preview' => 'Email Preview',
58+
'html_source' => 'HTML Source',
3259
];

resources/lang/hr/email.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,31 @@
2929
'recipient_email' => 'E-mail adresa primatelja',
3030
'invalid_cc_email' => 'Jedna ili više CC e-mail adresa nije valjana.',
3131
'invalid_bcc_email' => 'Jedna ili više BCC e-mail adresa nije valjana.',
32+
33+
// Mail Log / Outbox
34+
'outbox' => 'Odlazni e-mailovi',
35+
'outbox_description' => 'Pregled svih odlaznih e-mailova',
36+
'email_details' => 'Detalji e-maila',
37+
'email_body' => 'Sadržaj e-maila',
38+
'metadata' => 'Metapodaci',
39+
'user_information' => 'Informacije o korisnicima',
40+
'headers' => 'Zaglavlja',
41+
'from' => 'Od',
42+
'to' => 'Za',
43+
'sent_at' => 'Poslano u',
44+
'message_id' => 'ID poruke',
45+
'status' => 'Status',
46+
'sent' => 'Poslano',
47+
'sending' => 'Šalje se',
48+
'failed' => 'Neuspješno',
49+
'sent_today' => 'Poslano danas',
50+
'sent_this_week' => 'Poslano ovaj tjedan',
51+
'back_to_outbox' => 'Natrag na odlazne poruke',
52+
'view_email' => 'Prikaži e-mail',
53+
'no_emails' => 'Nema pronađenih e-mailova',
54+
'email_log' => 'Dnevnik e-mailova',
55+
'show_html' => 'Prikaži HTML',
56+
'show_preview' => 'Prikaži pregled',
57+
'email_preview' => 'Pregled e-maila',
58+
'html_source' => 'HTML kod',
3259
];

resources/lang/sl/email.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,31 @@
2929
'recipient_email' => 'Prejemnik e-pošte',
3030
'invalid_cc_email' => 'En ali več CC e-poštnih naslovov ni veljavnih.',
3131
'invalid_bcc_email' => 'En ali več BCC e-poštnih naslovov ni veljavnih.',
32+
33+
// Mail Log / Outbox
34+
'outbox' => 'Odhodna e-pošta',
35+
'outbox_description' => 'Pregled vse odhodne e-pošte',
36+
'email_details' => 'Podrobnosti e-pošte',
37+
'email_body' => 'Vsebina e-pošte',
38+
'metadata' => 'Metapodatki',
39+
'user_information' => 'Podatki o uporabnikih',
40+
'headers' => 'Glave',
41+
'from' => 'Od',
42+
'to' => 'Za',
43+
'sent_at' => 'Poslano ob',
44+
'message_id' => 'ID sporočila',
45+
'status' => 'Status',
46+
'sent' => 'Poslano',
47+
'sending' => 'Pošiljanje',
48+
'failed' => 'Neuspešno',
49+
'sent_today' => 'Poslano danes',
50+
'sent_this_week' => 'Poslano ta teden',
51+
'back_to_outbox' => 'Nazaj na odhodna sporočila',
52+
'view_email' => 'Prikaži e-pošto',
53+
'no_emails' => 'Ni najdenih e-poštnih sporočil',
54+
'email_log' => 'Dnevnik e-pošte',
55+
'show_html' => 'Prikaži HTML',
56+
'show_preview' => 'Prikaži predogled',
57+
'email_preview' => 'Predogled e-pošte',
58+
'html_source' => 'HTML koda',
3259
];

resources/lang/sr/email.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,31 @@
2929
'recipient_email' => 'Imejl adresa primaoca',
3030
'invalid_cc_email' => 'Jedna ili više CC imejl adresa nije validna.',
3131
'invalid_bcc_email' => 'Jedna ili više BCC imejl adresa nije validna.',
32+
33+
// Mail Log / Outbox
34+
'outbox' => 'Odlazni imejlovi',
35+
'outbox_description' => 'Pregled svih odlaznih imejlova',
36+
'email_details' => 'Detalji imejla',
37+
'email_body' => 'Sadržaj imejla',
38+
'metadata' => 'Metapodaci',
39+
'user_information' => 'Informacije o korisnicima',
40+
'headers' => 'Zaglavlja',
41+
'from' => 'Od',
42+
'to' => 'Za',
43+
'sent_at' => 'Poslano u',
44+
'message_id' => 'ID poruke',
45+
'status' => 'Status',
46+
'sent' => 'Poslano',
47+
'sending' => 'Šalje se',
48+
'failed' => 'Neuspešno',
49+
'sent_today' => 'Poslano danas',
50+
'sent_this_week' => 'Poslano ove nedelje',
51+
'back_to_outbox' => 'Nazad na odlazne poruke',
52+
'view_email' => 'Prikaži imejl',
53+
'no_emails' => 'Nema pronađenih imejlova',
54+
'email_log' => 'Dnevnik imejlova',
55+
'show_html' => 'Prikaži HTML',
56+
'show_preview' => 'Prikaži pregled',
57+
'email_preview' => 'Pregled imejla',
58+
'html_source' => 'HTML kod',
3259
];

src/EclipseServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
use Eclipse\Core\Console\Commands\ClearCommand;
99
use Eclipse\Core\Console\Commands\DeployCommand;
1010
use Eclipse\Core\Console\Commands\PostComposerUpdate;
11-
use Eclipse\Core\Listeners\SendEmailSuccessNotification;
1211
use Eclipse\Core\Console\Commands\SetupReverb;
1312
use Eclipse\Core\Health\Checks\ReverbCheck;
13+
use Eclipse\Core\Listeners\LogEmailToDatabase;
14+
use Eclipse\Core\Listeners\SendEmailSuccessNotification;
1415
use Eclipse\Core\Models\Locale;
1516
use Eclipse\Core\Models\User;
1617
use Eclipse\Core\Models\User\Permission;
@@ -86,6 +87,7 @@ public function register(): self
8687
});
8788

8889
Event::listen(MessageSent::class, SendEmailSuccessNotification::class);
90+
Event::listen(MessageSent::class, LogEmailToDatabase::class);
8991

9092
$this->app->register(AdminPanelProvider::class);
9193

0 commit comments

Comments
 (0)