1
votes

I have created a User Registration page with verifying mail using Laravel 7. But my markdown mail is not working. Giving "InvalidArgumentException No hint path defined for [mail]. (View: C:\xampp\htdocs\user_mgmt\resources\views\mail\VerifyMail.blade.php)" error.

Here is my RegistrationController Page.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Users_Profile;
use App\User;
use App\Mail\VerifyMail;
use Sentinel;
use Activation;
use Mail;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
    function register(Request $req)
    {
        $users_profile= new Users_Profile;

        $this->validate($req, [
            'username' => ['required', 'string', 'max:50', 'unique:users', 'alpha_dash'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);

        $user = Sentinel::register($req->all());
        
        $users_profile->email=$req->input('email'); 
        $users_profile->save();

        $req->session()->put('user',$req->input('username'));
        
        $activate = Activation::create($user);
        $this->sendActivationEmail($user, $activate->code);
        return redirect('verify');
    }

    public function sendActivationEmail($user, $code) {
        Mail::send(
            'mail.VerifyMail',
            ['user' => $user, 'code' =>$code],
            function($message) use ($user) {
                $message->to($user->email);
                $message->subject("Hello $user->name Activate Your Account.");
            }
        );
    }
}

Here is my Mail Blade Template

@component('mail::message')
#Thank you for registering in LMS

Please, click on the Link below to activate your account

@component('mail::button', ['url' => 'www.google.com' ])
Verify
@endcomponent

Thanks,<br>
{{ config('app.name') }}
@endcomponent

In my Mail controller I am using markdown instead of view in the build function.

1

1 Answers

0
votes

Your should use a mailable. It's cleaner and more concise. In Laravel, each type of email sent by your application is represented as a "mailable" class. To fix your case, you need to call the markdown() method in the build() method of your mailable - not the view() method. See the example below:

/**
 * Build the message.
 *
 * @return $this
 */
 public function build()
 {
     return $this->from('[email protected]')
                 ->markdown('emails.orders.shipped');
 }