If you have local setup via Homestead or Valet, you might need to use
smtp setup for emails in your application. For local development, one of the choices is to use MailHog.
Setting up MailHog can be in many ways but in this article, we will talk about setting up docker container for it.
Following are the steps:
- Install docker desktop
You can go to this link and choose the desired application for your operating system.
- Create a folder called
- Go to the folder and create a new file
cd docker-workspace touch docker-compose.yml
docker-compose.ymlfile and enter the following content:
version: "3.7" services: # SMTP Server smtp: platform: linux/x86_64 image: mailhog/mailhog container_name: docker-workspace-smtp logging: driver: 'none' ports: - "8003:1025" - "8100:8025" networks: - docker_workspace_network networks: docker_workspace_network: driver: bridge
- Start the docker container via the following command:
docker-compose up -d
- Go to http://localhost:8100/ and confirm the MailHog setup and you should see the following on successful setup
- In your Laravel application change the
.envto the following:
MAIL_MAILER=smtp MAIL_HOST=localhost MAIL_PORT=8003 MAIL_USERNAME='' MAIL_PASSWORD='' MAIL_ENCRYPTION=null
- Now, sending emails from you app will start showing up in the MailHog