Mailhog ERR_CONNECTION_REFUSED & Could not instantiate mail function

Hi there,

For some reason Mailhog is not working for me in development. First time this happens.
Yes I have SSL enabled locally and yes I added the hsts_max_age parameter like stated in the docs and re-reprovisioned my local VM.

I also cleared the hsts cache in my browser for the domain, but I just keep getting a

ERR_CONNECTION_REFUSED

error.

Also Gravityforms gives me a warning:

WordPress was unable to send the notification email. Could not instantiate mail function.

So I verified my sSMTP credentials on staging and I can send emails from there with these.
Then I ssh’d into my dev VM and I noticed sSMTP is not installed, is this normal behaviour?

What else could be happening?
Maybe related; this is my first project on my M1 Macbook Pro with Parallels Pro.

Thanks!

I think there’s still an unsolved issue about Mailhog on ARM: Trellis and Apple Silicon · Issue #1253 · roots/trellis · GitHub

I’m going to assume that if you haven’t manually done this workaround, then that’s the first thing to investigate.

1 Like

Ah check, did not see that post before!
Presumably I have to set that here:

Thanks!

Just put these two lines in group_vars/development/all.yml:

mailhog_binary_url: "https://github.com/evertiro/MailHog/releases/download/v1.0.1-M1/MailHog_linux_arm64"
mhsendmail_binary_url: "https://github.com/evertiro/mhsendmail/releases/download/v0.2.0-M1/mhsendmail_linux_arm64"
3 Likes

Jup, that was it! I did have to destroy my VM though.
Thing is, my colleague doesn’t have a M1 chip, so if he would re-provision his VM, Mailhog won’t work for him. Is there a way to add these lines conditionally based upon your arch?

Good question…

Normally you could create files with the architecture name and dynamically include them:

- include_vars: "{{ ansible_architecture }}.yml"

But since the mailhog role is vendored it makes it harder. Maybe you could just add that include_vars at the top in the dev.yml playbook.

I know the x86 arch is x86_64, you’d have to find what the ARM one is.

Thanks, that helped!
I put this at the top of my dev.yml:

- hosts: all
  tasks:
    - debug:
        msg: "{{ ansible_architecture }}"
    - name: Include architecture specific ansible vars
      include_vars:
        file: "{{ item }}"
      with_first_found:
        - files:
          - "{{ ansible_architecture }}.yml"
          skip: true
          errors: ignore

This will include my local aarch64.yml file with my ARM vars:

mailhog_binary_url: "https://github.com/evertiro/MailHog/releases/download/v1.0.1-M1/MailHog_linux_arm64"
mhsendmail_binary_url: "https://github.com/evertiro/mhsendmail/releases/download/v0.2.0-M1/mhsendmail_linux_arm64"
1 Like