Mailgun/Contact Form 7 Not Working (Domain is verified in Mailgun)

Hello,

I need ssmtp working so my Contact Form 7 submissions don’t fail or hang.

I have an account set up and verified on Mailgun, and have added the setup info into the group_vars/all/mail.yml file:

# Documentation: https://roots.io/trellis/docs/mail/
mail_smtp_server: smtp.mailgun.org:465
mail_admin: dev@domain.com
mail_hostname: mg.domain.com
mail_user: postmaster@mg.domain.com
mail_password: "{{ vault_mail_password }}" # Define this variable in group_vars/all/vault.yml

When provisioning the server everything seems fine and there is no issue during the ssmtp task. I’ve also tried different ports for the smtp server and they don’t seem to change the outcome. I’ve also left off the domain on the user variable and that also didn’t seem to matter.

However my CF7 forms still do not function. I have also installed the Mailgun WP plugin and when I put in my information and attempt to test the configuration, it always fails.

This site is using a Lets Encrypt SSL, if that has any impact.

I am not experienced with Mailgun, and I haven’t set up anything beyond adding the domain and DNS records and verifying them and activating the account. Is there additional setup required?

Thanks for your assistance.

Hi graphbb,

I’m having the exact same issue. Did you manage to fix it in the end?

Thanks

For anyone still struggling with this, here is how I got it working. The trick in my case was setting up a password for the default Mailgun SMTP user ‘postmaster@mg.mydomain.com’ and then adding that as the ‘mail_password’ value in Trellis.

In /group_vars/all/mail.yml:

mail_smtp_server: smtp.mailgun.org:587
mail_admin: postmaster@mg.mydomain.com  # Mailgun's default SMTP login account
mail_hostname: mydomain.com
mail_user: postmaster@mg.mydomain.com  # Same as mail_admin above
mail_password: "{{ vault_mail_password }}"  # Define this variable in group_vars/all/vault.yml`

In /group_vars/all/vault.yml:

vault_mail_password: "default_password_for_mail_user"  # Create this password for your default user in Mailgun. Surround it in double quotes here so Trellis doesn't choke.

In Contact Form 7, under the “Mail” config tab

To: info@mydomain.com
From: contact-form@mydomain.com

Finally, after altering config files, run ansible-playbook server.yml -e env=your_environment_here --tags ssmtp to reprovision for mail-related stuff only.

2 Likes