Mailhog not intercepting email in dev when real SMTP credentials are configured

I’ve configured real SendGrid credentials in trellis/group_vars/development/mail.yml because I want to use them with the SendGrid SMTP API in a plugin I’m developing. Now regular email sent by Wordpress is no longer being intercepted by Mailhog, I guess because the configured smtp server is no longer localhost:1025?

My understanding based on the Trellis docs was that Mailhog could still intercept mail in development even when real credentials were supplied.

From the docs

“Another benefit of using MailHog is that if are using real SMTP credentials in development, you can ensure you don’t accidentally send emails to real email addresses which might exist in your database.”

Is what I’m trying to do possible or just crazy?

What version of trellis?

Latest version 0.9.6

Did you happen to get a chance to look into this?

When features in Trellis are connected to ansible-galaxy roles, it’s good to consult the role’s docs as these will be more up to date and comprehensive than what we can maintain in the Trellis docs.

Mailhog works on a catch and release basis. So when you have an email you want to send from dev to your smtp gateway, you open Mailhog, select release on the appropriate mail and enter in the settings for your live smtp gateway.

You can also set up the details via ansible (copied from the ansible-role-mailhog docs) :

mailhog_install_ssmtp: true

Whether or not this role should additionally install ssmtp (which will replace any existing sendmail binary). If set to false, none of the ssmtp_* variables will have an effect.

ssmtp_mailhub: localhost:1025
ssmtp_root: postmaster
ssmtp_authuser: ""
ssmtp_authpass: ""
ssmtp_from_line_override: "YES"

Thanks, this clarifies what looks like just my misunderstanding of that line in your docs and inexperience with Mailhog and SMTP. I really appreciate the response.

1 Like