[Tutorial] How to add MailHog to Laragon and make it autorun using Procfile


  • administrators
    | 87399 points

    Here's how:

    1. Download MailHog:
      https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_windows_amd64.exe
    2. Move it to `C:\laragon\usr\bin\MailHog.exe
    3. Open Laragon's Procfile (Menu > Laragon > Procfile) and add these lines:
    MailHog: MailHog.exe autorun
    MailHog Admin: http://localhost:8025 autorun
    

    That's all. I hope you enjoyed yourself :)


  • administrators
    | 87399 points

    1 liner (using Menu > Laragon > Terminal):

    cd %LARAGON_ROOT%\usr & curl -L https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_windows_amd64.exe > bin\MailHog.exe & echo MailHog: MailHog.exe autorun >> Procfile & echo MailHog Admin: http://localhost:8025 autorun >> Procfile
    

  • | 354 points

    Thank you. I opened URL and it is working.
    Just to find out how to connect it with Laragon (PHP) PHPMailer function.
    Sent few messages via contact forms on different websites and Inbox still shows (0).


  • | 389 points

    @Stagger-Lee
    MailHog will act as a local smtp server, so when you create the smtp connection with PHPMailer, you need to give it the following settings:

    MAIL_DRIVER=smtp
    MAIL_HOST=127.0.0.1
    MAIL_PORT=1025
    MAIL_USERNAME=testuser
    MAIL_PASSWORD=testpwd
    

    Ports can change depending on the config you set up MailHog with. It's also possible that it won't require any authentication... depends on the use case.


  • | 354 points

    Thank you @blackfyre. Lost some time because of overflow of options for WordPress code. Now it is OK.

    Here it is a few lines plugin for WordPress. Just install it as any plugin. Or take action hook out and use in custom functions.php. Maybe better to install as a plugin. Later can be deleted. Less risk later will remain on production site and ruin mail sending.

    0_1521830434741_development-mail.zip


  • | 354 points

    Is there any way to make saving mails persistent ? Some other GPL script for collecting localhost mails ? Some other solution.

    It would help a lot by tweaking newsletters, and all possible HTML format mails, contact forms. As it is now not very useful. Restart Laragon and mails are gone.


  • | 389 points

    @Stagger-Lee Mailhog isn't ment to be persistent in any way. If you want persistence, I suggest you try mailtrap.io for that.

    But I cannot imagine why would anyone want persistence for local email development... I've been doing it for years and I'm happy to see them go away at the end of the day...


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.