<?php
namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class CustomEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $emailSubject;
    public $emailContent;
    public $recipientName;

    public function __construct($subject, $content, $recipientName = null)
    {
        $this->emailSubject = $subject;
        $this->emailContent = $content;
        $this->recipientName = $recipientName;
    }

    public function build()
    {
        return $this->subject($this->emailSubject)
                    ->view('emails.custom')
                    ->with([
                        'content' => $this->emailContent,
                        'recipientName' => $this->recipientName
                    ]);
    }
}
