![]() ![]() Remove the semi-colon and set its value to mhsendmail: sendmail_path = /usr/local/bin/mhsendmail If you have never modified it, it will look like this: sendmail_path = ![]() ![]() Next, let’s connect PHP to MailHog at both web server and CLI’s php.ini files. For example, I use Ubuntu 16.04, so I used these commands: ~]$ wget ~]$ sudo chmod +x ~]$ sudo mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail Then make it available in your system path. Start by opening the mhsendmail’s releases page and download the one for your system. To send outgoing email from PHP to MailHog, we need to download mhsendmail and then reference it at php.ini. Connecting PHP’s email with MailHog through mhsendmail In the next section, we will install mhsendmail, so PHP sends outgoing email to MailHog. Not setting the loopback IP address to the container would mean that anyone connected to the same network could access MailHog’s resources. The -publish flag maps the container's internal IP address to 127.0.0.1 on the host machine. MailHog by default listens on 0.0.0.0, which means whatever internal IP address is assigned to the Docker container. Now let’s look at its log to verify that it started correctly: ~]$ docker logs mailhogĦ 21:20:08 Binding to address: 0.0.0.0:1025Ĭheck out the above output: MailHog’s web interface is running at 0.0.0.0:8025. The above command will print the container identifier and then exit because we requested Docker to run the container in the background. Start automatically via -restart=unless-stopped.Expose MailHog’s web interface and API locally via -publish=127.0.0.1:8025:8025.Set a label to the container via -name=mailhog.Run a Docker container in the background via -detach.See, it’s just one command: ~]$ docker run -detach \ Let’s download the Docker image and run a container as a daemon, so it starts automatically the next time we boot the system. Running MailHog in the background with Docker If you prefer to install MailHog manually and keep it running as a Systemd service, then check out the companion article Installing MailHog for Ubuntu 16.04. The easiest and most cross-platform one that I found is by using the Docker image plus mhsendmail. There are several ways to install MailHog: downloading it from GitHub, through a Go package, using Homebrew, or using Docker. Hence I am sharing my personal experience in this article in hopes that it can serve as a time saver. While MailHog’s developer experience is awesome, it took me a while to figure out how to install and configure it. I saw that it had a considerable amount of activity on GitHub so I decided to try it. It was via the Docker4Drupal project (a Docker-based foundation for Drupal projects) that I discovered MailHog, a debugging SMTP server. I found custom scripts but not a tried and true best practice. This time, however, I wanted to analyze email going through so I searched for ways to redirect outgoing email to a log. Normally, I'd shortcircuit outgoing email from getting sent from my personal computer via one of the methods outlined at Oh no! My laptop just sent notifications to 10,000 users. We are migrating the site to a newer infrastructure so in order to verify that the subscription system works as expected I wanted to run a few tests. There is a standard subscription system that notifies editors when someone makes changes to content. These days I am helping Iowa State University with one of their websites.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |