How to Send Email in Laravel Using Sendinblue


Hi friends, today I will explain how to send email in laravel using Sendinblue email service provider. Sendinblue is very fast and smooth to send emails within a second. Actually, I am very disappointed about email sending via gmail smtp because Gmail often changes its policy. As you all know, earlier Gmail has a feature of less secure app access with ON and OFF.

Also read, Laravel custom authentication step-by-step tutorial

If you ONN this feature then Gmail will allow you to receive emails in your inbox while sending emails through Gmail SMTP but if you OFF this feature then Gmail will not allow emails to enter your mailbox. But nowadays, this feature is not available in Gmail.

Aside, you can generate an app password from Gmail but that is also not working as expected. That is why I have used the Sendinblue email service provider. Sendinblue provides the facility to send 300 emails per day currently. In order to send emails using sendinblue you can follow the below steps.

Required steps to send email in Laravel using Sendinblue

Step 1:- Create an account in Sendinblue.

Step 2:- Complete the process of sendinblue account verification by following the instructions received in your mailbox.

Step 3:- Now, login to your Sendinblue account and click the SMTP & API settings on the right side under username as shown below.

send email in laravel using Sendinblue

Step 4:- Now, get the SMTP details as shown below.

send email in laravel using Sendinblue

Step 5:- Now, configure the .env file of your Laravel project as shown below.

MAIL_MAILER=smtp
MAIL_HOST=smtp-relay.sendinblue.com
MAIL_PORT=587
MAIL_USERNAME=your sendinblue email
MAIL_PASSWORD=master password shown on the above image
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your sendinblue email
MAIL_FROM_NAME="${APP_NAME}"

if you do not know how to create a laravel project then read the below article.

How to create laravel project from scratch step by step

Step 6:- Now, set up the routes in the web.php file under the routes folder of your project as shown below.

Route::get('send-mail', [UploadFileController::class,'sendmail']);
Route::post('send-email', [UploadFileController::class,'sendemail']);

Step 7:- Now, create a controller using the below artisan command.

php artisan make:controller MailController

Step 7:- Now, create a mailable class using the artisan command as shown below.

php artisan make:mail myMail

you will find the mailable class under App\Mail\

Step 8:- Now, modify the MailController as given below.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Mail;
use App\Mail\myMail;

class MailController extends Controller
{
    //
    public function sendmail()
    {
      //dd('ok');
      return view('sendmail');
    }

    public function sendemail(){

        $details = [
            'title' => 'Mail from pbphpsolutions.com',
            'body' => 'Welcome to pbphpsolutions. We are now able to send email without gmail smtp server.'
        ];

        Mail::to('receivers email')->send(new myMail($details));
        //dd('Mail Sent');
        //return "Email sent successfully";
        return redirect('/send-mail')->with('success','Email has been sent successfully');
    }
}

Step 9:- Now, modify myEmail.php as shown below.

<?php

namespace App\Mail;

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

class myMail extends Mailable
{
    use Queueable, SerializesModels;
    public $details;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        //
        $this->details = $details;
    }

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

        return $this->subject('Mail from PBPHPSOLUTIONS.COM')
        ->view('mails.myMail');
    }
}

Step 10:- Now, create a myMail.balde.php file under resources/views/mails/ as given below.

<!DOCTYPE html>
<html>
<head>
    <title>pbphpsolutions.com</title>
</head>
<body>
    <p>{{ $details['title'] }}</p>
    <p>{{ $details['body'] }}</p>
    <br>
    <p>
    	<b><i>Thanx and Regards,</i></b><br>
    	pbphpsolutions
    </p>
</body>
</html>

Step 11:- Now, create another sendmail.blade.php file under resources/views as given below.

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">

    <title>Send email in Laravel using Sendinblue!</title>
	   
  </head>
  <body>

  	<form method="post" action="/send-email">
  	@csrf
  		<div class="container-fluid" style="width: 50%;">
  			<br>
  			@if(Session::has('success'))
  			<div class="alert alert-success" role="alert">
			  {{Session::get('success')}}<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" style="text-align: right;"></button>
			</div>
  			@endif
	  		<h3>Send email in Laravel using Sendinblue!</h3>
	  		<div class="mb-3">
			  <label for="exampleFormControlInput1" class="form-label">Email address</label>
			  <input type="email" class="form-control" name="email" id="exampleFormControlInput1">
			</div>
			<div class="mb-3">
			  <label for="exampleFormControlTextarea1" class="form-label">Message</label>
			  <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="message"></textarea>
			</div>
			<div class="mb-3">
			  <button type="submit" class="btn btn-primary btn-sm">Send</button>
			</div>
	  	</div>
  	</form>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
  </body>
</html>

Step 12:- Now, open your browser and hit the URL https://127.0.0.1:8000/send-mail and you can see the HTML form as shown below.

Step 13:- After sending the message, you can see the output as shown below.

Step 14:- Now, you can check your mailbox whether the email was received or not as shown below.

Also read, How to send mail in laravel 8 using SMTP Gmail

Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.


Leave a Comment

THOR311 RTP

RATU311

RATU311

RATU311

THOR311

THOR311

THOR311

RATU311

RATU311

KUPU178

KUPU178

RATU311

RATU311

RATU311

Mahjong Ways 2

CERI188

CERI188

sv388

CERI188

KUPU178 TOTO SLOT

CERI188

CERI188 TOTO Singapore

KUPU178

RATU311

sabung ayam online

THOR311

parlay

RATU311

KUPU178

RATU311

RATU311

KUPU178

KUPU178

KUPU178

RATU311

RATU311

CERI188

CERI188

KUPU178

RATU311: Alternatif karnpuracollege

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

KUPU178

RATU311

RATU311

RATU311

judi bola

live casino

sv388

sv388

sabung ayam online

sabung ayam online

Thor311 Terbaru

CERI188: Taruhan Bola Sbobet

THOR311 MAHJONG

RATU311: BONUS SABUNG AYAM

CERI188

parlay

KUPU178

RATU311

THOR311

RATU311

RATU311

RATU311

RATU311

RATU311

CERI188

CERI188: Masuk Akun Slot Super Cepat

KUPU178: Slot Online Mahjong Bet 200

THOR311 PRO

THOR311

CERI188

CERI188

CERI188

CERI188

CERI188

CERI188

CERI188

CERI188

THOR311

HOKI311

HOKI311

RATU311

RATU311

KUPU178

THOR311

KUPU178

THOR311

RATU311

HOKI311

KUPU178

KUPU178

RATU311

THOR311 TOTO4D

KUPU178

Live Casino Roullate

RATU311

RATU311

RATU311

RATU311

THOR311

THOR311

THOR311

RATU311

CERI188

DAFTAR KUPU178

LINK DAFTAR CERI188

CERI188

KUPU178

CERI188

CERI188

RATU311

KUPU178

THOR311 DOMINO QQ

judi bola online

Mix Parlay

CERI188

CERI188

RATU311

live casino online

RATU311

Mix Parlay

Slot PG Soft

CERI188

RATU311

RATU311

CERI188

THOR311

CERI188

THOR311

Game Thor311

THOR311

HOKI311

live casino

sv388

HOKI311

HOKI311

slot mahjong

Thor311 Alternatif

RATU311

HOKI311

HOKI311

HOKI311

HOKI311

CERI188

THOR311 RESMI

THOR311 AKSES

parlay

HOKI311

THOR311

RATU311 NONTON BOLA

CERI188 Link RTP LIVE

THOR311

Thor311 Live Casino

CERI188

akses VIP THOR311

THOR311

link daftar THOR311

THOR311

situs thor311

RATU311

HOKI311 Link SABUNG AYAM RESMI

HOKI311 Link QRIS EWALLET

RATU311

LINK CERI188

parlay

HOKI311 Link RTP Gacor

HOKI311 Link Apk Resmi

CERI188

KUPU178 Link Daftar

CERI188

CERI188

CERI188

CERI188

CERI188

HOKI311

RATU311

RATU311

HOKI311 Lapak Arena Slot

RATU311 judi bola

HOKI311 Link Spaceman Online

HOKI311 Link Daftar Resmi

CERI188 Toto SGP Online

KUPU178

HOKI311 TEMBAK IKAN ONLINE

KUPU178

HOKI311 Link Login Alternatif

HOKI311 Live Casino Online

HOKI311 Situs Slot Gacor

THOR311

THOR311

situs judi bola

Ceri188 Game Online

CERI188

link login CERI188

link login CERI188

CERI188

THOR311

HOKI311

HOKI311

CERI188

parlay

THOR311

RATU311

HOKI311

HOKI311

HOKI311

RATU311

THOR311

KUPU178

HOKI311

KUPU178

KUPU178

HOKI311

parlay

slot gacor

kupu178 link alternatif

kupu178 slot

kupu178 daftar

kupu178 login

link daftar kupu178

judi bola

HOKI311

RATU311

link alternatif RATU311

Link daftar RATU311

link login RATU311

RATU311

RATU311

KUPU178

KUPU178

THOR311

KUPU178

KUPU178

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

THOR311

KUPU178

KUPU178

HOKI311

THOR311

KUPU178

THOR311

THOR311

slot thailand

judi bola

THOR311

THOR311

KUPU178

THOR311

THOR311

slot gacor

slot gacor

yakuza303

unobet77

slot gacor

slot gacor

RATU311

parlay

parlay

slot gacor

parlay

THOR311