user12380208
user12380208

Reputation: 531

In laravel mail not sending it's showing errors

I have created a custom registration form and I am sending confirmation mail but it's showing an error

error

Process could not be started [The system cannot find the path specified.]

controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Http\Controllers\Controller;
use App\Contact;
use App\Student;
use App\Center;
use Illuminate\Support\Str;

use App\Mail\WelcomeMail;
use Illuminate\Support\Facades\Mail;
class MainpageController extends Controller
{

public function franchise_registration(Request $request)

    { 

      $this->validate($request, [


          'center_name' => 'required|string|max:255',
          'center_head' => 'required|string|max:255',
          'contact_no' => 'required|string|max:255',
          'email' => 'required|string|max:255',

        ]);



       $input['center_code']  ="KA_SIIT/".time();
       $input['center_name'] = strtoupper ($request['center_name']);
       $input['center_head'] = strtoupper ($request['center_head']);
       $input['contact_no'] = $request->contact_no;
       $input['email'] = $request->email; 

Center::create($input);

Mail::to($input['email'])->send(new WelcomeMail($input));
return redirect('franchise')->with('success','YOUR REGISTRATION SUCCESSFULLY. .');
   } 
} 

mailable

use App\Center;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class WelcomeMail extends Mailable {
  use Queueable, SerializesModels;
  public $user; 
  /**
   * Create a new message instance.
   *
   * @return void
   */
  public function __construct($user) { 
    $this->user = $user;
  }

  /**
   * Build the message.
   *
   * @return $this
   */
  public function build() { 
    return $this->view('emails.confirmation');
  } 
}

Mails confirmation view

<!DOCTYPE html>
<html>
<head>
    <title>Welcome Email</title>
</head>

<body>
<h2>Welcome to the site {{$input['center_name']}}</h2>
<br/>
Your registered email-id is {{$input['email']}}
</body>

</html>

Mail drive

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=*********
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=null

Upvotes: 1

Views: 384

Answers (1)

vipul sorathiya
vipul sorathiya

Reputation: 1316

Please make sure that you got $input array in mail template or not.

If not than please use $user array in mail template because you pass $user in __construct.

Upvotes: 1

Related Questions