Send email via Gmail SMTP server in Laravel 7/6

Today, We want to share with you Send email via Gmail SMTP server in Laravel 7/6.In this post we will show you Sending beautiful emails with laravel?, hear for How To Send Email From Localhost Using Laravel we will give you demo and example for implement.In this post, we will learn about Send Beautiful HTML Email using Laravel with an example.

Send email via Gmail SMTP server in Laravel 7/6

There are the Following The simple About Send mail vias Gmail SMTP server in Laravel 7/6 Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP Laravel 5.6 – Send Email using Mail Example, so the laravel send mail from localhost for this example is following below.

Read Also:  jquery empty/null json object Example

More Details for Pakainfo Blog:Free Download Example – Pakainfo.com

Setting up the Mail Driver

First of all Go to this link and Simple signup setup a account. https://mailtrap.io/register/signup

Open .env

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

Generating Mailables

php artisan make:mail LiveSimpleMail

App/Mail/LiveSimpleMail.php

<?php

namespace App\Mail;

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

class LiveSimpleMail extends Mailable
{
    use Queueable, SerializesModels;

    public $user;
    public function __construct()
    {
         $this->user = $user;
    }


    public function build()
    {
        return $this->view('emails.demo');
    }
}

Laravel Email View File

resources/views/emails/demo.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>PHP Laravel 7/6 - Send Email using Mail Example</title>
</head>

<body>
<h2>Welcome to the pakainfo.com web site</h2>
<br/>
  This is a simple email demo from pakainfo.come
  <h1>Mail from pakainfo.com</h1>
  <p>Thank you, {{ $user->name }}</p>
</body>

</html>

Sending Email

app/Http/Controllers/HomeController.php

public function index()
{
    $email = Auth::user()->email;
    Mail::to($email)->send(new LiveSimpleMail());
    return view('home');
}

Pakainfo
Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Laravel Send Email Attachment Tutorial With Example

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.


I hope you get an idea about Send email via Gmail SMTP server in Laravel 7/6.
I would like to have feedback on my Pakainfo blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.