Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

theokafadaris/chatwire

158 stars
2 code files
View theokafadaris/chatwire on GitHub

app/Mail/SendChatToEmail.php

Open in GitHub
use 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 GitHub
use 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);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.