Laravel Send Emails Mailgun setup Tutorial

Today, We want to share with you Laravel Send Emails Mailgun setup Tutorial.In this post we will show you Mailgun setup with Laravel 5 example, hear for Emails with Laravel 5.7 Mailables we will give you demo and example for implement.In this post, we will learn about Send email in Laravel through email sending services with an example.

Laravel Send Emails Mailgun setup Tutorial

There are the Following The simple About Laravel Send Emails Mailgun setup Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Send Emails Using PHP Mailgun , so the some How To Send Email In Laravel Tutorial for this example is following below.

  • Laravel configration(.env file)
  • Global Setting Of the Mailgun
  • Define Laravel Route
  • Create a Controller
  • Laravel Send Email Template View File
Read Also:  Laravel Aggregate Object and Debugging eloquent methods

Sttep 1 : setting of the Laravel configration

open .env file and bellow code

add configration on mail Sending Emails with Laravel and Mailgun

[email protected]
[email protected]

Good, now I required to Include secret key as well as your domain of mailgun send mail api configration. Therefor I make a new account in offical website SignUp and then I registeration and active your simple step to mailgun new account as well as click on simple tabs Like Domails Into Add New Domail button.

Step 2 : Global Setting Of the Mailgun


And then We have to open Laravel services.php file as well as put here simple mailgun configration key and url this way :

Read Also:  select query in php mysql with example

 'mailgun' => array(
    'domain' => '',
    'secret' => 'key-225487c09e58-056a9e692c96dd832jd0cc',

Step 3 : Define Laravel Route


After I am step 3 ready to each client send mail for first welcome so first usnig laravel 5.4, 5.5, 5.6 and 5.7 make welcome route for email sending.

Route::get('mail', '[email protected]');

Step 4 : Create a Controller


Good way, Then add simple send mail function in SendMailController.php file there for add Laravel this way :

public function mail()
    $client = Client::find(1)->toArray();
    Mail::send('emails.simpleSendMailTemplate', $client, function($message) use ($client) {
        $message->subject('Laravel Mailgun Testing');
    dd('Mail Send Successfully');

Laravel mailgun Send Mail
      try {
            $data = [
            $sent = Mail::send('emails.simpleSendMailTemplate', $data, function($message) {
                $message->from('[email protected]', 'Example Person');
                $message->to('[email protected]');
                $message->subject('Laravel Send Emails Mailgun setup Tutorial - Mailgun Testing');
            if( ! $sent) dd("something wrong");
            dd('Mail Send Successfully');
        catch (GenericHTTPError $e) {
           // return $e->getMessage();

Step 5 : Laravel Send Email Template View File


Read Also:  Laravel Installer Create Web Application install scripts

At Final step to make Laravel email template file for mailgun send mail therefor let’s make a simpleSendMailTemplate.blade.php file in emials folder.

<h1>Laravel Send Emails Mailgun setup Tutorial</h1>
Hi, I am from from mailgun testing.

Jaydeep Gondaliya

Angular 6 CRUD Operations Application Tutorials

Read :


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

I hope you get an idea about Laravel Send Emails Mailgun setup Tutorial.
I would like to have feedback on my 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:  Simple Get Category ID using Category Name
  2. Read Also:  Concept of Encapsulation in PHP OOP Example
  3. Read Also:  PHP Laravel Inline CRUD Using jQuery and AJAX
  4. Read Also:  Top 5 Free Dynamic ZIP Generation Libraries in PHP
  5. Read Also:  Ajax Dynamic Dependent Dropdown using Laravel Example
  6. Read Also:  laravel Add cascade on delete (ON DELETE CASCADE)
  7. Read Also:  Laravel Increment and Decrement Example
  8. Read Also:  Create Dynamic hide and show Tabs content in Angularjs
  9. Read Also:  PayPal Payment Gateway with PHP MySQL Database
  10. Read Also:  How to Open URL in New Tab using Drupal