Mail system resolved under Homebrew

Did some work on mail related interfaces and now have competent holding bin for system related mail relative to crontab, wordpress, and phpservermon. Mailhog and update of various elements was the answer to have easy solution for mail capturing without dealing with external SMTP servers and configuration.

Mailhog sits as a launch-able site to review mail generated by these systems. Keeps it in a nice holding location for easy review.

$ brew install mailhog

Installation via brew was easy, although configuration of Postfix was critical:

/etc/postfix/main.cf

#Gmail SMTP
#relayhost=smtp.gmail.com:587
#Enable SASL authentication in the Postfix SMTP client.
#smtp_sasl_auth_enable=yes
#smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
#smtp_sasl_security_options=noanonymous
#smtp_sasl_mechanism_filter=plain

#Enable Transport Layer Security (TLS), i.e. SSL.
#smtp_use_tls=yes
#smtp_tls_security_level=encrypt
#tls_random_source=dev:/dev/urandom
#smtputf8_enable = no
 compatibility_level = 2
 
#MailHog
 myhostname = localhost
 relayhost = [127.0.0.1]:1025

Key is to comment out everything gmail related (never worked anyway for some reason) and add the mailhog configuration as suggested through install documentation. Keep compatibility_level=2 for proper logging and operation. Worked well and stable. Mailhog has to be started in Brew:

$ brew services start mailhog

By the way, figured out that my use of apachectl was screwing up brew services, so no longer using “sudo apachectl -k restart” – that pushes web services to the SU level and causes a conflict with Brew. By using sudo apachectl to stop and “brew services start http” everything was fixed. Additionally, added the following to crontab:

#restart commands
 @reboot brew services restart httpd

Now, when there is a crash (still happening occasionally), restart and login causes httpd to automatically restart. Much more functional. If I can set it to do this without logging in, I’ll get it running automatically at runtime and without login.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.