Loading…

How can we configure a mail-in laravel?

Laravel provides a powerful and clean API over the SwiftMailer library with drivers for Mailgun, SMTP, Amazon SES, SparkPost, and send an email. With this API, we can send email on a local server as well as the live server.

Here is an example through the mail()

Laravel allows us to store email messages in our views files. For example, to manage our emails, we can create an email directory within our resources/views directory.

Example

                                        
public function sendEmail(Request $request, $id)
    {
        $user = Admin::find($id);

        Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
            $m->from('info@bestinterviewquestion.com', 'Reminder');

            $m->to($user->email, $user->name)->subject('Your Reminder!');
        });
    }

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel Interview Questions

Ask Question