dan3460
203
5
Laravel

Mail send not working

Posted 1 year ago by dan3460

I have look around on google but i think my problem is different of just misspelled or wrong setup file. Right now i have the .env setup for mailtrap, using Tinker i can send a simple email using Email::raw(). So the configuration is working. I have the following method to send an email:

    public function sendForm()
    {
        Mail::send('emails.contact',[
            'name'=>request('customerName'),
            'email'=>request('customerEmail'),
            'phone'=>request('customerPhone'),
            'msg'=>request('customerMessage'),
            'pref'=>request('commPreference')
        ], function($msg){
            $msg->from('[email protected]');
            $msg->to('[email protected]', 'Admin')->subject('Web Site Request');
        });
  
        //return redirect('/')->with('message', 'We will get back to you very soon....Thanks');
    }

I commented the return to make sure that i was hitting the method, i'm getting a blank page. So i'm hitting the method. i typed the mail command in tinker, replacing the requests with hard coded data and it worked. How i can troubleshoot that the method is actually calling the mail function?

Please sign in or create an account to participate in this conversation.