---
description: >-
  https://www.itsolutionstuff.com/post/how-to-send-mail-using-mailjet-in-laravelexample.html
---

# How to Send Mail using Mailjet in Laravel?

## How to Send Mail using Mailjet in Laravel?

By Hardik Savani January 19, 2021 Category : Laravel![](https://a.vdo.ai/core/assets/img/cross.svg)PlayUnmuteLoaded: 1.17%Fullscreen[![VDO.AI](https://a.vdo.ai/core/assets/img/logo.svg)](https://vdo.ai/?utm_medium=video\&utm_term=itsolutionstuff.com\&utm_source=vdoai_logo)Hi,

If you need to see example of how to send mail using mailjet in laravel. i would like to share with you laravel send mail mailjet example. you'll learn laravel mailjet smtp example. Here you will learn laravel mailjet send email. Alright, let’s dive into the steps.

we can easily send mail using mailjet driver in laravel 6, laravel 7, laravel 8 and laravel 9 app.

In this example, i will give you step by step instruction to send email in laravel using mailjet. you can create blade file design and also with dynamic information for mail layout. so let's see step by step guide and send email to your requirement.

**Step 1: Add Configuration**

First you need to create account on mailjet if you don't have. So click bellow link to create account:

[MailJet Site: https://www.mailjet.com](https://www.mailjet.com/)

After creating account and domain active you have to go bellow url as like bellow screen shot:

[Setup Page: https://app.mailjet.com/account/setup](https://app.mailjet.com/account/setup)

you have to pickup, MAILJET\_APIKEY and MAILJET\_APISECRET with other configuration.

![](https://www.itsolutionstuff.com/upload/laravel-mail-jet.png)

Next you have to go here:

[Sender Page: https://app.mailjet.com/account/sender](https://app.mailjet.com/account/sender)

Here you have to take active email for MAIL\_FROM\_ADDRESS.

![](https://www.itsolutionstuff.com/upload/laravel-mail-jet2.png)

add details from there bellow:

.env

```
MAIL_DRIVER=mailjetMAIL_HOST=in-v3.mailjet.comMAIL_PORT=587MAIL_USERNAME=f693d7b0...MAIL_PASSWORD=5670494...MAIL_ENCRYPTION=tlsMAIL_FROM_ADDRESS=od..@gmail.comMAIL_FROM_NAME="${APP_NAME}"  MAILJET_APIKEY=f693d...MAILJET_APISECRET=5670494b057...
```

now you have to add mail driver on mail.php config file as like bellow:

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 step we will create mail class MyTestMail for email sending. Here we will write code for which view will call and object of user. So let's run bellow command.

```
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');    }}
```

Read Also: [How to add text on image in Laravel?](https://www.itsolutionstuff.com/post/how-to-add-text-on-image-in-laravel-5example.html)

**Step 3: Create Blade View**

In this step, we will create blade view file and write email that we want to send. now we just write some dummy text. create bellow files on "emails" folder.

resources/views/emails/myTestMail.blade.php

```
<!DOCTYPE html><html><head>    <title>ItsolutionStuff.com</title></head><body>    <h1>{{ $details['title'] }}</h1>    <p>{{ $details['body'] }}</p>       <p>Thank you</p></body></html>
```

**Step 4: Add Route**

Now at last we will create "MyTestMail" for sending our test email. so let's create bellow web route for testing send email.

routes/web.php

```
Route::get('send-mail', function () {       $details = [        'title' => 'Mail from ItSolutionStuff.com',        '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.");});
```

Now you can run and check example.

It will send you email, let' see.

Run Project:

```
php artisan serve
```

Open Link:

Read Also: [Laravel Send Mail using Mailgun Example](https://www.itsolutionstuff.com/post/laravel-send-mail-using-mailgun-exampleexample.html)

```
localhost:8000/send-mail
```

Output:

![](https://www.itsolutionstuff.com/upload/laravel-7-mail-2.png)

I hope it can help you...
