Laravel Mailgun Setup Example

Laravel Mailgun Setup Example

In this post we will give you information about Laravel Mailgun Setup Example. Hear we will give you detail about Laravel Mailgun Setup ExampleAnd how to use it also give you demo for it if it is necessary.

Mailgun is very popular API to send email from website. It is very fast to send mail and also it track the mail. Tracking email is very important feature of mailgun api and you can also see how much user open your mail, click on your mail too. Mailgun send mail like work gun. In this post i would like to show you how to setting of mailgun in our laravel 5 application. In this example you can learn to send simple mail using mailgun api. If you are use mailgun for sending email then you can save loading time and you can get mail fast.

First we will add configration on mail. i added my gmail account configration. so first open .env file and bellow code:






Ok, now we need to add secret and domain of mailgun api configration. So first create new account in SignUp if you don’t have before. After registeration active your mailgun account and click on Domails and click on Add New Domail button. then you can see bellow screen.

After add name you can see bellow screen and copy domain name and API Key from like bellow image.

Now you have to open services.php and add mailgun configration this way :


 'mailgun' => array(

'domain' => 'onlinecode',

'secret' => 'key-11796c09e58-056a9e975c96dd334da0dd',


Now we are ready to send mail for test so first create test route for email sending.


Route::get('mail', 'HomeController@mail');

Ok, now add mail function in HomeController.php file so add this way :


public function mail()


$user = User::find(1)->toArray();

Mail::send('emails.mailEvent', $user, function($message) use ($user) {


$message->subject('Mailgun Testing');


dd('Mail Send Successfully');


At last create email template file for send mail so let’s create mailEvent.blade.php file in emials folder.


Also see:Laravel Mailchimp api integration from scratch with example

Hi, I am from from mailgun testing.

Now try…

Hope this code and post will helped you for implement Laravel Mailgun Setup Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  37  =  41

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US