Mailgun / Trellis

There are a few posts on mailgun / trellis, but none of them answer a particular question I have…

I have mailgun working on multiple sites with the following config, but the emails are often flagged as junk which makes me wonder if the following is fully correct.

mail_password: "{{ vault_mail_password }}"

My question: Is mail_admin or mail_user supposed to be the actual email that is sending the emails (e.g. rather than them both being the default SMTP login (i.e. If so, which one?

Quick sanity check: does your config actually say, or does it say your domain name?

Presuming it’s your domain name: have you created and verified all of the recommended DNS entries at Mailgun, including the MX records?

Yeah, I only changed it to for this post.

I’ve created, verified and double checked everything, and all has been working since day one… But a good portion of the mail gets flagged as junk (mosty with hotmail accounts) and I read somewhere that a mismatch of sending addresses can be the cause of that, which is what brought me here.

The email address that WordPress uses to send emails comes from WordPress and not from anything in Trellis

Yeah, I know that it’s set outside of trellis, I’m just verifying that it doesn’t have to match one of the ones in trellis?

They’re just SMTP credentials… your questions at this point don’t really seem to be specific to Trellis. Have you looked into Mailgun support?

Yeah, that’s the first place I started, which is what brought up the confusion with the trellis config.

Mailgun aside, what are the differences / uses of mail_admin and mail_user

You can see the whole SMTP role in the project, go take a look and see :slight_smile:

Where exactly do I look to understand the role of mail_admin and mail_user?

The only references I can find are in mail.yml (op) and ssmtp.conf.j2 (below), which I don’t fully understand:

# {{ ansible_managed }}

root={{ mail_admin }}
AuthMethod={{ ssmtp_auth_method }}
FromLineOverride={{ ssmtp_from_override }}
UseTLS={{ ssmtp_tls }}
UseSTARTTLS={{ ssmtp_start_tls }}
hostname={{ mail_hostname }}
mailhub={{ mail_smtp_server }}
{% if mail_user is defined %}
AuthUser={{ mail_user }}
{% endif %}
{% if mail_password is defined %}
AuthPass={{ mail_password }}
{% endif %}

There is no mention of mail_admin in the docs.

You could also check whether you’re changing the “from” address in your form tool. Gravity Forms lets you change the “from” which would look suspicious to many spam tools.

I probably should have mentioned, but it’s actually woocommerce that is sending the emails in the projects in question. Similarily, I have set the “from” portion of it to something along the lines of, which doesn’t match the in the trellis config.

This is where my initial question comes in; If these values should match eachother to not look “suspicious”?

I figured it out. For anybody else who may find themselves here:

  • the emails do need to match for best results
  • if you want your emails to come from an address other than
    • create a “New SMTP Credential” from the Mailgun dashboard (e.g.
    • use that email and password in your Trellis config
    • also use that email as your Wordpress / WooCommerce “From” address
  • you should immediately notice that emails no longer get flagged as spam… or at least less than before