Skip to content

Instantly share code, notes, and snippets.

@rseon
Created November 14, 2022 12:08
Show Gist options
  • Save rseon/bab508e6b60e647a4a797803ac1dda84 to your computer and use it in GitHub Desktop.
Save rseon/bab508e6b60e647a4a797803ac1dda84 to your computer and use it in GitHub Desktop.
Mailhog + WampServer + Laravel

Mailhog + WampServer + Laravel

Mailhog

  • Download Mailhog from Github releases
  • Copy and rename the downloaded file to C:\wamp64\bin\mailhog.exe

WampServer

Edit following files :

  • C:\wamp64\bin\apache\apache[VERSION]\bin\php.ini (which is shortcut to C:\wamp64\bin\php\php[VERSION]\phpForApache.ini)
  • C:\wamp64\bin\php\php[VERSION]\php.ini

And change following lines :

-smtp_port = 25
+smtp_port = 1025

Then :

Test

Put this script in a file test-mail.php :

<?php
   $to = '[email protected]';
   $subject = 'Hello from WampServer!';
   $message = 'This is a Mailhog test';
   $headers = "From: [email protected]\r\n";

   if (mail($to, $subject, $message, $headers)) {
      echo "SUCCESS";
   } else {
      echo "ERROR";
}

Then run it with php test-mail.php

Mail will be shown in your browser.

Laravel

Edit .env file :

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null

Thanks

Thanks to this gist and this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment