-
app/Mail/SendChatToEmail.php
Open in GitHubuse Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Queue\SerializesModels; class SendChatToEmail extends Mailable { use Queueable, SerializesModels; public $email; public function __construct($email) { $this->email = $email; } public function envelope(): Envelope { return new Envelope( subject: 'Mail from Laravel Livewire ChatGPT', ); } public function content(): Content { return new Content( view: 'emails.chatbox', with: [ 'email' => $this->email, ], ); } public function attachments(): array { return []; } }
-
app/Jobs/SendEmailJob.php
Open in GitHubuse App\Mail\SendChatToEmail; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; class SendEmailJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; protected $details; public function __construct($details) { $this->details = $details; } public function handle(): void { Log::info('Sending email to '.$this->details['email']); $email = new SendChatToEmail($this->details); Mail::to($this->details['email'])->send($email); } }