Laravel Mail

By | October 12th 2018 04:07:10 PM | viewed 289 times

add any one of the following set code to .env file to setup mail:




Run the following code:

D:\xampp_726\htdocs\ptm > php artisan config:cache

Add a class in this location:App\Mail


namespace App\Mail;

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

use Illuminate\Http\Request;
use Auth;
use App\Http\Requests;
use App\User;

class UserRegisMail extends Mailable
    use Queueable, SerializesModels;

    public  $to_email ="";
    public  $to_name ="";
	public  $cc_email ="";
    public  $cc_name ="";
    public  $subject ="";
    public  $userIns = null;
    public  $password = null;
    public  $businessOwnerUserIns = null;
    public  $ecShowroomIns = null;
    public function __construct($to_email,$to_name,$cc_email,$cc_name,$subject,$userIns,$password,$businessOwnerUserIns,$ecShowroomIns)
                $this->to_email = $to_email;
                $this->to_name = $to_name;
				$this->cc_email = $cc_email;
                $this->cc_name = $cc_name;
                $this->subject = $subject;
                $this->userIns = $userIns;
                $this->password = $password;
                $this->businessOwnerUserIns = $businessOwnerUserIns;
                $this->ecShowroomIns = $ecShowroomIns;

    public function build()
        return $this->view('emails.user_regi_mail')
                //->from($address, $name)
                //->replyTo($address, $name)

create the view in the location:resources\views\emails\user_regi_mail.blade.php

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8"> 
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">   
<body style="font-size:12px;color:#000000;">
  <div style="width:100%;padding:0 10px;clear:both;">
            <div style="clear:both;">
                         <div style="width:150px;float:left;vertical-align: bottom;">
                                <a href="{{\URL::to('/')}}"><img style="width:150px;" src="{{$message->embed(asset('public/images/upload/logo/qrius.png')) }}"></a>
                         <div style="width:300px;float:right;vertical-align: baseline;position:absolute;right:10px;top:60px;">
                                          $date = \Carbon\Carbon::now('Asia/Dhaka');
                                         {{'Date: '}} {{\Carbon\Carbon::parse($date)->format('F jS Y h:i:s A')}}               
    <div style="clear:both;border-top:1px solid #cccccc;"> </div>
    <div style="clear:both;">
        <h5>Welcome to {{@$userIns->first_name}}{{@$userIns->last_name}}</h5>
               Your User Id: {{@$userIns->email}} / {{@$userIns->mobile}}<br/>
               Your password: {{@$password}}<br/>
     <div style="clear:both;">
         <div style="clear:both;border-top:1px solid #cccccc;"> </div>
            <p class="footerPara marginZero" align="center">
                Copyright 2020 by QRIUS. All Rights Reserved.
                  |  Powered by QRIUS  

Now call this class from any controller as follows:

<?php namespace App\Http\Controllers\Ecommerce;

use App\Mail\UserRegisMail;
use Illuminate\Support\Facades\Mail;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Carbon\Carbon;
use DB;
use Auth;
use Illuminate\Support\Facades\URL;

class EcOrderController extends Controller {

 public function orderSuc(Request $request){
     $sendmailSts ="ok";
     $userRegisMail = new UserRegisMail($to_email,$to_name,$cc_email,$cc_name,$subject,$userIns,$password,$businessOwnerUserIns,$ecShowroomIns);  // to render html
            $sendmailSts = Mail::to($to_email,$to_name)
            if($sendmailSts == null){
               return 1; 
                return 0;

Total : 2848

Today :31

Today Visit Country :

  • Singapore
  • Ireland
  • Bangladesh
  • United States
  • Sweden
  • Japan
  • United Kingdom
  • India
  • France
  • Russia