Scott Bendlock

Scott Bendlock

1574648447

How to Send Email Notification in Laravel 6?

In this tutorial, I will guide you how to send email notification in Laravel 6. We will create Laravel 6 notification to email address. We will send email to notify user using Laravel 6 notification system.

Using laravel 6 notifications, you can send email, send sms, send slack message notification to user. in this example I give you very simple way to create first notification to send mail in Laravel 6. we can easily create Notification by laravel artisan command. We can easily customization of notification like mail subject, mail body, main action etc. We almost require to use notification when we work on large amount of project like e-commerce. Might be you need to send notification for payment receipt, order place receipt, invoice etc.

In this example we will create email notification and send it to particular user, than we saved to database. So, you need to follow few step to make basic example with notification.

Step 1: Install Laravel 6

I am going to explain step by step from scratch so, we need to get fresh Laravel 6 application using bellow command, So open your terminal OR command prompt and run bellow command:

composer create-project --prefer-dist laravel/laravel blog

Step 2: Create Database Table

In this step, we need to create “notifications” table by using laravel 5 artisan command, so let’s run bellow command:

php artisan notifications:table
php artisan migrate

Step 3: Create Notification

In this step, we need to create “Notification” by using laravel 5 artisan command, so let’s run bellow command, we will create MyFirstNotification.

php artisan make:notification MyFirstNotification

Now you can see new folder will create as “Notifications” in app folder. You need to make following changes as like bellow class.

app/Notifications/MyFirstNotification.php

<?php

   

namespace App\Notifications;

   

use Illuminate\Bus\Queueable;

use Illuminate\Notifications\Notification;

use Illuminate\Contracts\Queue\ShouldQueue;

use Illuminate\Notifications\Messages\MailMessage;

   

class MyFirstNotification extends Notification

{

    use Queueable;

  

    private $details;

   

    /**

     * Create a new notification instance.

     *

     * @return void

     */

    public function __construct($details)

    {

        $this->details = $details;

    }

   

    /**

     * Get the notification's delivery channels.

     *

     * @param  mixed  $notifiable

     * @return array

     */

    public function via($notifiable)

    {

        return ['mail','database'];

    }

   

    /**

     * Get the mail representation of the notification.

     *

     * @param  mixed  $notifiable

     * @return \Illuminate\Notifications\Messages\MailMessage

     */

    public function toMail($notifiable)

    {

        return (new MailMessage)

                    ->greeting($this->details['greeting'])

                    ->line($this->details['body'])

                    ->action($this->details['actionText'], $this->details['actionURL'])

                    ->line($this->details['thanks']);

    }

  

    /**

     * Get the array representation of the notification.

     *

     * @param  mixed  $notifiable

     * @return array

     */

    public function toDatabase($notifiable)

    {

        return [

            'order_id' => $this->details['order_id']

        ];

    }

}

Step 4: Create Route

In this is step we need to create routes for sending notification to one user. so open your “routes/web.php” file and add following route.

routes/web.php

Route::get('send', 'HomeController@sendNotification');

Step 4: Create Controller

Here,we require to create new controller HomeController that will manage generatePDF method of route. So let’s put bellow code.

app/Http/Controllers/HomeController.php

<?php

  

namespace App\Http\Controllers;

  

use Illuminate\Http\Request;

use App\User;

use Notification;

use App\Notifications\MyFirstNotification;

  

class HomeController extends Controller

{

    /**

     * Create a new controller instance.

     *

     * @return void

     */

    public function __construct()

    {

        $this->middleware('auth');

    }

  

    /**

     * Show the application dashboard.

     *

     * @return \Illuminate\Contracts\Support\Renderable

     */

    public function index()

    {

        return view('home');

    }

  

    public function sendNotification()

    {

        $user = User::first();

  

        $details = [

            'greeting' => 'Hi Artisan',

            'body' => 'This is my first notification from ItSolutionStuff.com',

            'thanks' => 'Thank you for using ItSolutionStuff.com tuto!',

            'actionText' => 'View My Site',

            'actionURL' => url('/'),

            'order_id' => 101

        ];

  

        Notification::send($user, new MyFirstNotification($details));

   

        dd('done');

    }

  

}

Now we are ready to send first notification to user. so let’s run our example so run bellow command for quick run:

php artisan serve

You can run following url:

http://localhost:8000/send

You can also send notification like this way:

$user->notify(new MyFirstNotification($details));

You can get sent notifications by following command:

dd($user->notifications);

I hope it can help you…

#Laravel #PHP #WebDev

What is GEEK

Buddha Community

How to Send Email Notification in Laravel 6?

Mohammad Fahad

1609135975

Hello,
Where did you hit the toMail function?

Mohammad Fahad

1610167386

What about .env file setting?

Send Email In Laravel

Hello Guys,

Today I will give you demo how to send email in laravel, in this post we will show how to send email using SMTP in laravel, email is very basic and most important feature in web development field and it is necessary for all client.

So, in this tutorial I will give you information about send mail in laravel. So, follow below steps.

Send Email In Laravel

https://websolutionstuff.com/post/send-email-in-laravel

#laravel #php #send email in laravel #email #how to send email in laravel #laravel send mail

Send Mail Example In Laravel 8

Hello Guys,

In this post i will give you demo Send Mail Example in Laravel 8.here i will show you how to send mail in laravel 8, email is very basic and most important feature in web development field and it is necessary for all client to send and receive information and important data.

So, in this tutorial i will give you information about send mail in laravel 8.

So, let’s start and follow below steps.

Read More : Send Mail Example In Laravel 8

https://websolutionstuff.com/post/send-mail-example-in-laravel-8


Read Also : Google Recaptcha Example In Laravel

https://websolutionstuff.com/post/google-recaptcha-example-in-laravel

#send mail example in laravel 8 #laravel #php #how to send mail in laravel 8 #email #laravel 8 send email

Ayan Code

1656193861

Simple Login Page in HTML and CSS | Source Code

Hello guys, Today in this post we’ll learn How to Create a Simple Login Page with a fantastic design. To create it we are going to use pure CSS and HTML. Hope you enjoy this post.

A login page is one of the most important component of a website or app that allows authorized users to access an entire site or a part of a website. You would have already seen them when visiting a website. Let's head to create it.

Whether it’s a signup or login page, it should be catchy, user-friendly and easy to use. These types of Forms lead to increased sales, lead generation, and customer growth.


Demo

Click to watch demo!

Simple Login Page HTML CSS (source code)

<!DOCTYPE html>
  <html lang="en" >
  <head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
  <link rel="stylesheet" href="styledfer.css">
  </head>

  <body>
   <div id="login-form-wrap">
    <h2>Login</h2>
    <form id="login-form">
      <p>
      <input type="email" id="email" name="email" placeholder="Email " required><i class="validation"><span></span><span></span></i>
      </p>
      <p>
      <input type="password" id="password" name="password" placeholder="Password" required><i class="validation"><span></span><span></span></i>
      </p>
      <p>
      <input type="submit" id="login" value="Login">
      </p>

      </form>
    <div id="create-account-wrap">
      <p>Don't have an accout? <a href="#">Create One</a><p>
    </div>
   </div>
    
  <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min.js'></script>
  </body>
</html>

CSS CODE

body {
  background-color: #020202;
  font-size: 1.6rem;
  font-family: "Open Sans", sans-serif;
  color: #2b3e51;
}
h2 {
  font-weight: 300;
  text-align: center;
}
p {
  position: relative;
}
a,
a:link,
a:visited,
a:active {
  color: #ff9100;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
}
a:focus, a:hover,
a:link:focus,
a:link:hover,
a:visited:focus,
a:visited:hover,
a:active:focus,
a:active:hover {
  color: #ff9f22;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
}
#login-form-wrap {
  background-color: #fff;
  width: 16em;
  margin: 30px auto;
  text-align: center;
  padding: 20px 0 0 0;
  border-radius: 4px;
  box-shadow: 0px 30px 50px 0px rgba(0, 0, 0, 0.2);
}
#login-form {
  padding: 0 60px;
}
input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  outline: none;
  height: 60px;
  line-height: 60px;
  border-radius: 4px;
}
#email,
#password {
  width: 100%;
  padding: 0 0 0 10px;
  margin: 0;
  color: #8a8b8e;
  border: 1px solid #c2c0ca;
  font-style: normal;
  font-size: 16px;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  position: relative;
  display: inline-block;
  background: none;
}
#email:focus,
#password:focus {
  border-color: #3ca9e2;
}
#email:focus:invalid,
#password:focus:invalid {
  color: #cc1e2b;
  border-color: #cc1e2b;
}
#email:valid ~ .validation,
#password:valid ~ .validation 
{
  display: block;
  border-color: #0C0;
}
#email:valid ~ .validation span,
#password:valid ~ .validation span{
  background: #0C0;
  position: absolute;
  border-radius: 6px;
}
#email:valid ~ .validation span:first-child,
#password:valid ~ .validation span:first-child{
  top: 30px;
  left: 14px;
  width: 20px;
  height: 3px;
  -webkit-transform: rotate(-45deg);
          transform: rotate(-45deg);
}
#email:valid ~ .validation span:last-child
#password:valid ~ .validation span:last-child
{
  top: 35px;
  left: 8px;
  width: 11px;
  height: 3px;
  -webkit-transform: rotate(45deg);
          transform: rotate(45deg);
}
.validation {
  display: none;
  position: absolute;
  content: " ";
  height: 60px;
  width: 30px;
  right: 15px;
  top: 0px;
}
input[type="submit"] {
  border: none;
  display: block;
  background-color: #ff9100;
  color: #fff;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
  font-size: 18px;
  position: relative;
  display: inline-block;
  cursor: pointer;
  text-align: center;
}
input[type="submit"]:hover {
  background-color: #ff9b17;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

#create-account-wrap {
  background-color: #eeedf1;
  color: #8a8b8e;
  font-size: 14px;
  width: 100%;
  padding: 10px 0;
  border-radius: 0 0 4px 4px;
}

Congratulations! You have now successfully created our Simple Login Page in HTML and CSS.

My Website: codewithayan, see this to checkout all of my amazing Tutorials.

How to Send E-mail Using Queue in Laravel 7/8

Today I will show you How to Send E-mail Using Queue in Laravel 7/8, many time we can see some process take more time to load like payment gateway, email send, etc. Whenever you are sending email for verification then it load time to send mail because it is services. If you don’t want to wait to user for send email or other process on loading server side process then you can use queue.

Read More : How to Send E-mail Using Queue in Laravel 7/8

https://websolutionstuff.com/post/how-to-send-e-mail-using-queue-in-laravel-7-8


Read Also : Send Mail Example In Laravel 8

https://websolutionstuff.com/post/send-mail-example-in-laravel-8

#how to send e-mail using queue in laravel 7/8 #email #laravel #send mail using queue in laravel 7 #laravel 7/8 send mail using queue #laravel 7/8 mail queue example

Send Email In Laravel

Hello Guys,

Today I will give you demo how to send email in laravel, in this post we will show how to send email using SMTP in laravel, email is very basic and most important feature in web development field and it is necessary for all client.

Send Email In Laravel

https://websolutionstuff.com/post/send-email-in-laravel

Thanks for the reading…!!

#send email in laravel #laravel #mail #beginners #how to send email in laravel #mail example