Setting Up Mail

I’ve read the docs on mail configuration here: https://roots.io/trellis/docs/mail/

I have a domain at mailgun configured and verified. I have updated the mail.yml file with my info as follows:

mail_smtp_server: smtp.mailgun.org:587
mail_admin: info@mydomain.com //not sure what i’m supposed to put here but it is an address on the domain
mail_hostname: mg.mydomain.com
mail_user: postmaster@mg.mydomain.com
mail_password: “{{ vault_mail_password }}” # Define this variable in group_vars/all/vault.yml

I’ve added the password to my vault and pushed everything. I redeployed the site.

Do I need to use the mailgun plugin to make email work? I’m getting timeouts when i try to add a new user and the check email plugin also dies when I try to test an email. Nothing in the logs other than the timeout.

Questions:

  • Do the values above look correct
  • Are there any more mail settings that need to be adjusted - ssMtp for example
  • Do I need to install the mailgun plugin after doing the setup described in the mail document?

Thanks in advance.

You redeployed but did you reprovision? To set up mail settings you must reprovision your server. The plugin is not necessary.

So to be clear, reprovision as follows:

ansible-playbook server.yml -e env=production

This is safe to run on a live site?

Yup and yup. Go for it.

Thanks for that @MWDelaney . I have attempted to run the command and am getting an error:

sudo: a password is required

I have root access to the box (i.e. i can login from the Digital Ocean console as root) but have also set up ssh keys for passwordless ssh access from a shell.

You’ve obviously provisioned this server before and it worked I assume right (since you have a working site)?

Where/when does that error happen? More terminal output/logs might be helpful.

1 Like

I have provisioned and it is a working site.Here is the terminal output from the provision run:

ansible-playbook server.yml -e env=production

PLAY [Ensure necessary variables are defined] ************************************************************************************

TASK [Ensure environment is defined] *********************************************************************************************
[DEPRECATION WARNING]: ansible.utils.unicode.to_unicode is deprecated.  Use ansible.module_utils._text.to_text instead.
This 
feature will be removed in version 2.4. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
skipping: [localhost]

PLAY [Determine Remote User] *****************************************************************************************************

TASK [remote-user : Require manual definition of remote-user] ********************************************************************
skipping: [myip]

TASK [remote-user : Check whether Ansible can connect as root] *******************************************************************
ok: [myip -> localhost]

TASK [remote-user : Set remote user for each host] *******************************************************************************
ok: [myip]

TASK [remote-user : Announce which user was selected] ****************************************************************************
Note: Ansible will attempt connections as user = admin
ok: [myip]

TASK [remote-user : Load become password] ****************************************************************************************
ok: [myip]

PLAY [Install prerequisites] *****************************************************************************************************

TASK [Install Python 2.x] ********************************************************************************************************
System info:
  Ansible 2.3.2.0; Darwin
  Trellis 0.9.8: August 14th, 2016
---------------------------------------------------
Shared connection to myip closed.

fatal: [myip]: FAILED! => {"changed": true, "failed": true, "rc": 1, "stderr": "Shared connection to myip closed.\r\n", "stdout": "sudo: a password is required\r\n", "stdout_lines": ["sudo: a password is required"]}
    to retry, use: --limit @/path/to/site/mydomain.com/trellis/server.retry

PLAY RECAP ***********************************************************************************************************************
myip              : ok=4    changed=0    unreachable=0    failed=1   
localhost                  : ok=0    changed=0    unreachable=0    failed=0

I figured it out. I had at some point changed the admin_user to admin but there is no admin user on the box. I changed it back to root and it is now provisioning.

Now to see if i can get this email business working…

1 Like

Ok email is sending through Mailgun. Interesting that it took quite awhile to go from “accepted” to “delivered” when looking at the mailgun logs.

1 Like