Email configuration debugging

Hello, we have Discourse running on our VPS (tutorial) behind NGINX, as it described here.

We would like to use SMTP server of Beget ( provider but email sending does not work. We don’t have enough debug information to solve this problem by ourselves.
We tried different settings and rebuild the app after each change.

Configuration (part of app.yml)
DISCOURSE_SMTP_PASSWORD: "edited-password"
DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
Output from discourse-doctor

==================== MAIL TEST ====================
For a robust test, get an address from
Sending mail to REDACTED  . . 
Testing sending to using
======================================== ERROR ========================================
                                    UNEXPECTED ERROR


====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to
(And a solution, if you find one!)

==================== DONE! ====================


  • Without DISCOURSE_SMTP_OPENSSL_VERIFY_MODE variable or with it and "none" value nothing changes - "Net::ReadTimeout"
  • Without DISCOURSE_SMTP_AUTHENTICATION: "login" we get same error - “Net::ReadTimeout”.
  • Changing DISCOURSE_SMTP_PORT to 25/2525 with DISCOURSE_SMTP_ENABLE_START_TLS: false - "504 PLAIN authentication mechanism not supported". (DISCOURSE_SMTP_AUTHENTICATION is set to “login”, I can see this value in admin area)
  • Changing DISCOURSE_SMTP_PORT to 25/2525 with DISCOURSE_SMTP_ENABLE_START_TLS: true - same "504 PLAIN authentication mechanism not supported". (DISCOURSE_SMTP_AUTHENTICATION is set to “login”, I can see this value in admin area)
  • Python script with different settings (port 25/465, with or without SSL) works fine on host and inside Discourse docker container.
Python code
import smtplib

def notify(server_account, target, message):
    server, login, password = server_account

    msgbox = smtplib.SMTP(server, port=25)

    msgbox.user = login
    msgbox.password = password
    msgbox.auth('LOGIN', msgbox.auth_login, initial_response_ok=True)
    msgbox.sendmail(login, target, message)

if __name__ == '__main__':
    smtp_server = ''
    sender = ''  # sender email
    password = 'edited-password'  # password

    server_account = (smtp_server, sender, password)

    target = ''  # target email

    subject = 'discourse test'
    body = '0049'
    message = """From: {0}\r\nTo: {1}\r\nSubject: {2}\r\n\r\n{3}""".format(sender, target, subject, body)

    notify(server_account, target, message)

But how can we debug deeper? Log file shared/standalone/log/rails/production.log does not contain any helpful information.

We also tried to follow this:

So, we moved on to Mailgun and its works fine. Looks like no one should use unpopular, but trusted services due to lack of troubleshooting abilities.

1 Like