Emails not being sent

I've just configured a new Elgg instance and all seems to be working correctly with one exception - it is not sending emails.

I've configured elgg to send email via SMTP using mailgun, which is a service I already use for another site which I run. However, the new user email confirmation and other emails are not being sent from Elgg.

Here are the settings I am using (password blacked out):

Screenshot of SMTP settings.

I've been fiddling with it for a while but I just can't see what is wrong with it.

When a user clicks to register, they see the spinning circle for about ten seconds then Elgg displays the message about clicking on the email it just sent them but no email ever arrives.

I've tried looking in the nginx error log but I don't see anything specific to the emails, and I really can't think of what else to try.