Home » Send email via Gmail SMTP server in Laravel 7/6

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.

Read Also:  Bootstrap Toggle switch Update Database field using Ajax

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.

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

Read Also:  laravel excel import Export to Database Example

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:  bootstrap 4 multiple image slider with thumbnail navigation

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Redirect page after delay using Vuejs
  2. Read Also:  Woocommerce Featured Image URL and Gallery images in Wordpress
  3. Read Also:  Laravel 5/6/7 CRUD Operations Example Step By Step
  4. Read Also:  PHP Laravel comma separated column join using MySQL
  5. Read Also:  PHP Laravel 7 Send Email Example Tutorial
  6. Read Also:  How to Send Emails in Laravel?
  7. Read Also:  sticky Scroll Back to Top Button using jQuery and CSS
  8. Read Also:  Angular 6 Registration and Login System Example Tutorial
  9. Read Also:  Laravel 5.5 - Get Last Inserted ID With Example
  10. Read Also:  Fadein Fadeout example using Jquery Example

Leave a Comment

Your email address will not be published. Required fields are marked *