Recent News

Mailable in Laravel to send email on signup for confirmation

you can use Laravel’s built-in Mail class to send a confirmation email when a user signs up.

Here are the steps you can follow:

  1. Set up your mail settings in the .env file. You’ll need to provide your email service provider’s SMTP credentials:


2. Create a new Mailable class using the php artisan make:mail command:

php artisan make:mail SignupConfirmation

3. Open the newly created SignupConfirmation class in the app/Mail directory and add the necessary code:

user = $user;

public function build()
return $this->view(’emails.signup_confirmation’)
->subject(‘Confirm your email address’);

In the above code, we are passing the user object to the constructor, which we can then use to populate the email content. We are also defining the email’s subject and the view that will be used to render the email.

4 Create a view for the email. In this example, we’ll create a file named signup_confirmation.blade.php in the resources/views/emails directory:

Welcome to our site, {{ $user->name }}!

Please click the link below to confirm your email address:

Leave a Reply

Your email address will not be published. Required fields are marked *