Issues with mail sending to SMTP relay

Hi,
we are having problems with sending emails via an SMTP relay with no user and password required. i am able to send emails to the relay using mailx / sendmail.
those are the settings.

 DISCOURSE_SMTP_ADDRESS: xyz.example.com (obfuscated)
 DISCOURSE_SMTP_PORT: 587
 DISCOURSE_SMTP_AUTHENTICATION: plain

what I get back, when using the discourse_doctor is giving this error.

Net::ReadTimeout

it appears to me like the SMPT message sent is mal-crafted as we send stuff, but we do not get anything back on port 587. this is provable with a Wireshark trace.

can you please elaborate how to put more verbose logging or additional debugging so we can further analyze the problem? the regular logs don’t tell me anything. i found backtrace, but I am not a ruby developer so cannot interpret this.

/usr/local/lib/ruby/3.2.0/net/protocol.rb:229:in `rbuf_fill'

/usr/local/lib/ruby/3.2.0/net/protocol.rb:199:in `readuntil'

/usr/local/lib/ruby/3.2.0/net/protocol.rb:209:in `readline'

net-smtp-0.3.3/lib/net/smtp.rb:1057:in `recv_response'

net-smtp-0.3.3/lib/net/smtp.rb:659:in `block in do_start'

net-smtp-0.3.3/lib/net/smtp.rb:1067:in `critical'

net-smtp-0.3.3/lib/net/smtp.rb:659:in `do_start'

net-smtp-0.3.3/lib/net/smtp.rb:611:in `start'

/var/www/discourse/vendor/bundle/ruby/3.2.0/bundler/gems/mail-5b700fc95ee6/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'

/var/www/discourse/vendor/bundle/ruby/3.2.0/bundler/gems/mail-5b700fc95ee6/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'

/var/www/discourse/vendor/bundle/ruby/3.2.0/bundler/gems/mail-5b700fc95ee6/lib/mail/message.rb:269:in `deliver!'

/usr/local/lib/ruby/3.2.0/delegate.rb:87:in `method_missing'

/var/www/discourse/lib/email/sender.rb:286:in `send'

/var/www/discourse/app/jobs/regular/user_email.rb:79:in `send_user_email'

/var/www/discourse/app/jobs/regular/user_email.rb:39:in `execute'

/var/www/discourse/plugins/chat/lib/chat/user_email_extension.rb:6:in `execute'

/var/www/discourse/app/jobs/base.rb:249:in `block (2 levels) in perform'

rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'

/var/www/discourse/app/jobs/base.rb:236:in `block in perform'

/var/www/discourse/app/jobs/base.rb:232:in `each'

/var/www/discourse/app/jobs/base.rb:232:in `perform'

sidekiq-6.5.8/lib/sidekiq/processor.rb:202:in `execute_job'

sidekiq-6.5.8/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'

sidekiq-6.5.8/lib/sidekiq/middleware/chain.rb:177:in `block in invoke'

/var/www/discourse/lib/sidekiq/pausable.rb:134:in `call'

sidekiq-6.5.8/lib/sidekiq/middleware/chain.rb:179:in `block in invoke'

sidekiq-6.5.8/lib/sidekiq/middleware/chain.rb:182:in `invoke'

sidekiq-6.5.8/lib/sidekiq/processor.rb:169:in `block in process'

sidekiq-6.5.8/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'

sidekiq-6.5.8/lib/sidekiq/job_retry.rb:113:in `local'

sidekiq-6.5.8/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'

sidekiq-6.5.8/lib/sidekiq.rb:44:in `block in <module:Sidekiq>'

sidekiq-6.5.8/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'

sidekiq-6.5.8/lib/sidekiq/processor.rb:263:in `stats'

sidekiq-6.5.8/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'

sidekiq-6.5.8/lib/sidekiq/job_logger.rb:13:in `call'

sidekiq-6.5.8/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'

sidekiq-6.5.8/lib/sidekiq/job_retry.rb:80:in `global'

sidekiq-6.5.8/lib/sidekiq/processor.rb:124:in `block in dispatch'

sidekiq-6.5.8/lib/sidekiq/job_logger.rb:39:in `prepare'

sidekiq-6.5.8/lib/sidekiq/processor.rb:123:in `dispatch'

sidekiq-6.5.8/lib/sidekiq/processor.rb:168:in `process'

sidekiq-6.5.8/lib/sidekiq/processor.rb:78:in `process_one'

sidekiq-6.5.8/lib/sidekiq/processor.rb:68:in `run'

sidekiq-6.5.8/lib/sidekiq/component.rb:8:in `watchdog'

sidekiq-6.5.8/lib/sidekiq/component.rb:17:in `block in safe_thread'

I downgraded the application to the latest stable release, which did not solve this problem. the guy working on this before is on PTO, so I cannot tell to which version this was before the latest update happened. I also realized, there were recent code changes in the mail area. maybe problems there ?

thank you

1 Like

You may be experiencing timeouts in your mail engine, this was mentioned in another recent topic. Postfix apparently has a 5 second timeout by default.

It took me several days of head-banging to get replies and posting via email working, lots of little things to get right both within Discourse and at your mail server, including mailer settings and firewall settings.

And I haven’t started to deal with mailer issues yet, specifically getting whitelisted at multiple ISPs. I do have SPF and DKIM working.

thanks for the answer, yes, but ai m searching for something which tells me, what the problem is. it’s tricky as the wireshark trace shows the e-mail is sent, but no response is given. normal e-mail using Linux sendmail works with no issue. SPF and DKIM is set on the respective domain as well. I am able to reproduce the issue on the rails console.

message = TestMailer.send_test(“ycxi@examle.com”)
Email::Sender.new(message, :test_message).send

I am not a ruby expert at all, I will see if I can get some more verbose logging than a stack trace:

[5] pry(main)> wtf?
Exception: Net::ReadTimeout: Net::ReadTimeout

we fixed a similar issue by increasing the SMTP timeout thresholds in the app.yml file - refering to this topic:

How the app.yml was modified:
image

After changing the yaml the app was rebuilt:
sudo ./launcher destroy app && sudo ./launcher start app

The change is reflected in the GUI
image