In case you want to see illustration of how to send letters utilizing mailjet in laravel. I might want to impart to you laravel send letters mailjet model. you’ll learn laravel mailjet smtp model. Here you will learn laravel mailjet send email. Okay, we should plunge into the means.

we can undoubtedly send letters utilizing mailjet driver in laravel 6, laravel 7 and laravel 8 application.

In this model, I will give you bit by bit guidance to send email in laravel utilizing mailjet. you can make edge document plan and furthermore with dynamic data for mail format. so we should see bit by bit direct and send email to your necessity.

Step 1: Add Configuration

First you want to make account on mailjet assuming you don’t have. So click roar connect to make account:

MailJet Site: https://www.mailjet.com

add subtleties from that point howl:

.env

MAIL_DRIVER=mailjet

MAIL_HOST=in-v3.mailjet.com

MAIL_PORT=587

MAIL_USERNAME=f653d7z0

MAIL_PASSWORD=56704353

MAIL_ENCRYPTION=tls

MAIL_FROM_ADDRESS=testxxx@xxx.com

MAIL_FROM_NAME=”${APP_NAME}”

MAILJET_APIKEY=f6934dr54fr.

MAILJET_APISECRET=56705435435

presently you need to add mail driver on mail.php config record as like roar:

config/mail.php

<?php

return [

    …..

    ‘mailers’ => [

        ….

        ‘mailjet’ => [

            ‘key’ => env(‘MAILJET_APIKEY’),

            ‘secret’ => env(‘MAILJET_APISECRET’),

            ‘transactional’ => [

                ‘call’ => true,

                ‘options’ => [

                    ‘url’ => ‘api.mailjet.com’,

                    ‘version’ => ‘v3.1’,

                    ‘call’ => true,

                    ‘secured’ => true

                ]

            ],

            ‘common’ => [

                ‘call’ => true,

                ‘options’ => [

                    ‘url’ => ‘api.mailjet.com’,

                    ‘version’ => ‘v3’,

                    ‘call’ => true,

                    ‘secured’ => true

                ]

            ]

        ]

    ]

]

Step 2: Create Mail

In this progression we will make mail class MyTestMail for email sending. Here we will compose code for which view will call and protest of client. So how about we run roar order.

php artisan make:mail MyTestMail

app/Mail/MyTestMail.php

<?php

 namespace App\Mail;

 use Illuminate\Bus\Queueable;

use Illuminate\Contracts\Queue\ShouldQueue;

use Illuminate\Mail\Mailable;

use Illuminate\Queue\SerializesModels;

 class MyTestMail 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->subject(‘Mail from ItSolutionStuff.com’)

                   ->view(’emails.myTestMail’);

   }

}

Step 3: Create Blade View 

In this progression, we will make edge view document and compose email that we need to send. presently we simply think of some spurious message. make howl documents on “messages” envelope.

resources/views/emails/myTestMail.blade.php

<!DOCTYPE html>

<html>

<head>

   <title>Test Mail</title>

</head>

<body>

   <h1>{{ $details[‘title’] }}</h1>

   <p>{{ $details[‘body’] }}</p>

   <p>Thank you!!</p>

</body>

</html>

Step 4: Add Route

Presently finally we will make “MyTestMail” for sending our test email. so how about we make howl web course for testing send email.

routes/web.php

Route::get(‘send-mail’, function () {

   $details = [

       ‘title’ => ‘Mail Title’,

       ‘body’ => ‘This is for testing email using smtp’

   ]; 

   \Mail::to(‘your_receiver_email@gmail.com’)->send(new \App\Mail\MyTestMail($details)); 

   dd(“Email is Sent Successfully!!!.”);

});

Run Project:

Presently you can run and really take a look at model.

php artisan serve

Leave A Comment

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