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.


  • You would use SMTP only if you can't (or do not want) to set up an MTA (e.g. postfix) on your server. If the mailserver is correctly set up on your server Elgg can likely make use of it without any configuration necessary. When sending mail from your own mailserver it might be necessary to use a from mail address (site email) from the same domain and maybe also some authentification functionality is necessary for your mails not getting blocked by mail providers (sender server domain and mail domain being different is not very trustworhty after all).

    I don't know what the rules regarding mail address domains are with SMTP. But I would imagine that a mail provider offering sending mails via SMTP over their servers would not like being miused by spammers either and therefore will requite usage of a mail address of their domain.

  • That's right iionly. There are too many issues with SMTP being blocked from my VPS. So I am using a third-party SMTP service called mailgun which works very well and comes with some great reporting and management tools.

    I'm using mailgun for another two websites that I admin, which also run on the same VPS, so I know that the configuration works just fine.

    However, for some reason Elgg is not communicating correctly with mailgun. I've checked the logs on mailgun and I can not see any rejected emails or anything like that so having isolated everything else to the best of my ability I have to assume that the problem is with Elgg's implementation of sending mail via SMTP.

    When I get some time I'll look at the code (hooray for open source) but I'm no expert on PHP/Zend. If I do come up with a solution I'll feed it back in the comments. I do like the layout and functionality of Elgg so I'll do a bit more work to try and get the email working before I junk it for something else.

  • It has been a long road figuring out how to solve this problem so I figure I may as well post my solution for those who come after me.

    Please bear in mind that I'm in no way an expert linux admin so what I'm about to say may seem obvious to others.

    What I didn't realise is that postfix can be used to relay mail to a third-party SMTP service rather than trying to send it directly. There are some instructions and a sample config on this page:

    So what I did was the following:

    1. Install postfix.
    2. Install libsasl2-modules.
    3. Edit /etc/postfix/
    4. Made the changes to relay mail via mailgun (my SMTP server).
    5. systemctl restart postfix
    6. Edit /path/to/elgg/elgg-config/settings.php
    7. Set $CONFIG->emailer_transport = 'sendmail';
    8. Commented out the SMTP settings.
    9. Send a test email with mutt. It works!
    10. Send a test verification with Elgg. It works!

    I hope this helps someone out there avoid some frustration and good luck!