Monday, May 22, 2017

How can send an email with Laravel 5.4 with Mail facade

I created a form to send an email. I created an email file named 'ContactMailFull' with the command php artisan make:mail ContactMailFull.

Here is my file

class ContactMailFull extends Mailable

{ use Queueable, SerializesModels;

public $name;
public $subject;
public $email;
public $description;


public function __construct(Request $request)
{
    $this->name        = $request->input('name');
    $this->subject     = $request->input('subject');
    $this->email       = $request->input('email');
    $this->description = $request->input('description');
}


public function build()
{

    return $this->view('mails.sendFull')
                ->subject($this->subject)
                ->from('guess@gmail.com', 'Guess')
                ->with([
                    'name' => $this->name,
                    'subject' => $this->subject,
                    'email' => $this->email,
                    'description' => $this->description
                ]);
}

}

I try to send the email but But it's not right. I know we have to do something like this.

Mail::to('my-email@gmail.com') with a New Something But I do not understand the documentation. And I do not know where I have to put it.

Can you help me ?

Thank you



via Jeremy

Advertisement