---
title: "Mail configuration in laravel 5"
id: "541"
type: "post"
slug: "mail-configuration-laravel-5"
published_at: "2016-04-28T12:14:18+00:00"
modified_at: "2019-08-14T07:41:14+00:00"
url: "https://eswasoft.com/mail-configuration-laravel-5/"
markdown_url: "https://eswasoft.com/mail-configuration-laravel-5.md"
excerpt: "In Laravel 5, mail configuration need to be done in .env file and mail.php files. In one of our projects, we have used the thrid party mail server ‘mailgun’ for sending mail. In .env file: MAIL_DRIVER=sendmail MAIL_HOST=smtp.mailgun.org MAIL_PORT=587 MAIL_USERNAME=YOUR USERNAME..."
taxonomy_category:
  - "Laravel"
  - "PHP"
taxonomy_post_tag:
  - "laravel"
  - "mail"
---

# Mail configuration in laravel 5

[Dhakshina](#post-author)
April 28, 2016

0 comments

In Laravel 5, mail configuration need to be done in .env file and mail.php files. In one of our projects, we have used the thrid  
 party mail server ‘mailgun’ for sending mail.

In .env file:

```
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=YOUR USERNAME
MAIL_PASSWORD=YOUR PASSWORD
MAIL_ENCRYPTION=tls
```

In the above configuration, the issue which we have faced was ‘mail driver’. Initially, it was ‘SMTP’ and then after lot of attempts,  
 we have used ‘sendmail’ as mail driver and it was worked ( Note: we have used godaddy hosting).

Once we configure the .env file and we need to add the same details in ‘config/mail.php’ file with additional information such as ‘from’ email address

In config/mail.php

```
return [

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'notification@chatur.phpgainers.com', 'name' => "Chatur"],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('postmaster@sandboxb76807a698754f1dbb01e4bd7c46e80f.mailgun.org'),
'password' => env('55098439658e30bb9956e6124c5cafe5'),
];
```

Note:

you need to make sure that ‘ from email address’ should have domain name where you have hosted your application. For example: your website name is www.example.com. then  
 your from mail address may be ‘notify@example.com’ or ‘contact@example.com’ and it should not be like ‘contact@someotherwebsite.com

#### Leave the first comment [(Cancel Reply)](/mail-configuration-laravel-5/#respond)
