In a Support thread titled “Mail test failure in discourse-doctor,” user philion reports consistent SMTP failures using ./discourse-doctor despite successful external tests via swaks and custom Ruby scripts. Initial configuration used DISCOURSE_SMTP_FORCE_TLS: true and DISCOURSE_SMTP_ENABLE_START_TLS: false, yielding “SMTP server connection successful. Sending mail failed. end of file reached.” thoka suggests adding DISCOURSE_SMTP_DOMAIN and debugging via stack trace. sam recommends this setting to avoid EHLO localhost rejections and advises testing via the admin panel instead of discourse-doctor. Despite rebuilding and adding debug logs, the error persists. philion confirms the issue is specific to Discourse’s SMTP handling, as manual Ruby scripts work. After multiple iterations — including updating app.yml with full email as username, reinstalling neovim for editing, and verifying credentials — the fix is revealed: ensuring DISCOURSE_SMTP_PASSWORD is quoted if it contains symbols, setting DISCOURSE_SMTP_FORCE_TLS: true, DISCOURSE_SMTP_ENABLE_START_TLS: false, and crucially, setting DISCOURSE_NOTIFICATION_EMAIL to a valid, existing email address. philion confirms email now works. The thread highlights long-standing, poorly documented SMTP configuration challenges in Discourse, especially with port 465, and underscores the importance of correct env vars and valid email addresses for DISCOURSE_NOTIFICATION_EMAIL.
==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@burlyqna.org]:
Sending mail to admin@burlyqna.org. . .
Testing sending to admin@burlyqna.org using smtp.mailfence.com:465, username:philion@mailfence.com with plain auth.
SMTP server connection successful.
Sending to admin@burlyqna.org. . .
Sending mail failed.
end of file reached
There is a lot of discussion about 465 in the support forums. Based on my reading, it looks like Discourse makes a lot of assumptions about SSL and TLS over SMTP, and there are a handful of env vars that control the detailed behaviors.
HOWEVER, given the number of reported errors and related questions in these forums, I have the strong impression that these settings are poorly documented and difficult to use. And seeing similar problems going back to 2017, this has been an issue for years now.
Searches for “port 465” or “Net::ReadTimeout smtp” can reveal a long list of similar issues.
I’m trying to find this file on the docker build, and I can’t. I see that it’s wrapped in a container, but I’ve cloned discourse/discourse_docker not discourse/discourse.
When I try to enter the app with launcher enter app, there’s no way to edit that file or to install vi.
I cannot find any docs or flags for running ./discourse-doctor with debug logs turned on.
Fails in the same way: Can’t send email, ./discourse-doctor reports the same error.
I updated passwords to remove symbols, waited for the SMTP auth propagation delay (long enough to make lunch), confirmed proper creds to correctly send email with swaks, and…
Same error.
I notice rebuilding removes the stacktrace dump, so I’m going to add that back and try ./launcher destroy app && ./launcher start app
==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@burlyqna.org]:
Sending mail to admin@burlyqna.org. . .
Testing sending to admin@burlyqna.org using smtp.mailfence.com:465, username:philion with plain auth.
SMTP server connection successful.
Sending to admin@burlyqna.org. . .
Sending mail failed.
end of file reached
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:237:in `rbuf_fill'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:199:in `readuntil'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:209:in `readline'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:1017:in `recv_response'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:1008:in `block in getok'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:1027:in `critical'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:1006:in `getok'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:986:in `quit'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:732:in `do_finish'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:645:in `ensure in start'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/net-smtp-0.5.1/lib/net/smtp.rb:645:in `start'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/message.rb:269:in `deliver!'
After a lot of testing, and a lot of help from @thoka, I offer the following summary:
I am able to run SMTP tests using the same creds that I have supplied container/app.yml that work with both swaks (Swaks - Swiss Army Knife for SMTP) and sample Ruby code provide by @thoka (see below).
These work consistently. However, trying to standup a Discourse server (which cannot send the initial email to the admin user) or using discourse-doctor bot result in email failures:
==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@burlyqna.org]:
Sending mail to admin@burlyqna.org. . .
Testing sending to admin@burlyqna.org using smtp.mailfence.com:465, username:xxx@mailfence.com with plain auth.
SMTP server connection successful.
Sending to admin@burlyqna.org. . .
Sending mail failed.
end of file reached
This seems to be a protocol config failure, as I’m able send test emails using standard Ruby tools:
require 'mail'
SMTP_SERVER = 'smtp.mailfence.com'
SMTP_PORT = 465
USERNAME = 'xyz'
PASSWORD = '...'
FROM = 'admin@burlyqna.org'
TO = 'testing@gmail.com'
SUBJECT = 'Test from Ruby'
BODY = "Hello,\n\nThis is a test email sent from Ruby over a SSL-secured connection.\n\nBest regards!"
Mail.defaults do
delivery_method :smtp, {
address: SMTP_SERVER,
port: SMTP_PORT,
user_name: USERNAME,
password: PASSWORD,
domain: "burlyqna.org",
enable_starttls_auto: :false,
authentication: :plain,
ssl: true,
}
end
begin
puts 'Sending email...'
puts "SMTP_SERVER: #{SMTP_SERVER}"
puts "SMTP_PORT: #{SMTP_PORT}"
puts "USERNAME: #{USERNAME}"
puts "PASSWORD: #{PASSWORD}"
puts "FROM: #{FROM}"
puts "TO: #{TO}"
mail = Mail.new do
to TO
from FROM
subject SUBJECT
body BODY
end
mail.deliver!
end