Configure SMTP in Docker container

When I deploy Discourse via Helm charts

helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-release bitnami/discourse

things work as intended, but I cannot modify the SMTP e-mail configuration in the Docker container.

When I try to replicate this, I shuttle in the container and execute

cd /opt/bitnami/discourse/config

in this dir I find the discourse.conf file, but I can’t modify it as it says, for instance, that vi is not available.

Do you have any suggestions what I could do?

You can ask on their forum. Except they closed it.

Or you can do a standard install and get help here.

You might be able to set env variables. You can look at the examples.

Hi @pfaffman , many thanks for your input.

I know now how to bring environment variables into the Bitnami helm chart.

Given the SMTP credentials of my provider for transactional e-mails Sendinblue

do you know how the environment variables do look like, that I have to pass to the Dsicourse container?

If you’re trying to use a regular gmail account to send mail, it’s a violation of the TOS and won’t work (for several other reasons).

There is an example of SMTP env variables in

1 Like

Hi @pfaffman @Falco

many thanks for your input.

This is how my environment variables look like

discourse:
  extraEnvVars:
    - name: DISCOURSE_SMTP_ADDRESS
      value: "smtp-relay.sendinblue.com"
    - name: DISCOURSE_SMTP_PORT
      value: "587"
    - name: DISCOURSE_NOTIFICATION_EMAIL
      value: "no-reply@my-domain.com"
    - name: DISCOURSE_SMTP_USER_NAME
      value: "my-email@googlemail.com"
    - name: DISCOURSE_SMTP_PASSWORD
      value: "my-pw"
    - name: DISCOURSE_SMTP_DOMAIN
      value: "my-domain.com"

and after that the container came up. I tried to send a test e-mail to my gmail account from the admin panel. This is what I got:

So it does not work by now.

These are the logs from the Discourse container:

Processing by Admin::UsersController#show as JSON
  Parameters: {"id"=>"1"}
Completed 200 OK in 1978ms (Views: 0.6ms | ActiveRecord: 0.0ms | Allocations: 195416)
Started GET "/groups/search.json" for 10.0.0.50 at 2022-08-10 11:55:05 +0000
Processing by GroupsController#search as JSON
Completed 200 OK in 1189ms (Views: 0.5ms | ActiveRecord: 0.0ms | Allocations: 133325)
Started GET "/admin/email.json" for 10.0.0.50 at 2022-08-10 11:55:17 +0000
Processing by Admin::EmailController#index as JSON
Completed 200 OK in 23ms (Views: 1.2ms | ActiveRecord: 0.0ms | Allocations: 864)
Started POST "/admin/email/test" for 10.0.0.50 at 2022-08-10 11:55:20 +0000
Processing by Admin::EmailController#test as */*
  Parameters: {"email_address"=>"test@gmail.com"}
Completed 422 Unprocessable Entity in 20ms (Views: 1.1ms | ActiveRecord: 0.0ms | Allocations: 2037)
Started GET "/about.json" for 10.0.0.47 at 2022-08-10 11:55:46 +0000
Processing by AboutController#index as JSON
Completed 200 OK in 67ms (Views: 0.3ms | ActiveRecord: 0.0ms | Allocations: 9503)
Started GET "/site/basic-info.json" for 10.0.0.47 at 2022-08-10 11:55:46 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 254ms (Views: 0.5ms | ActiveRecord: 0.0ms | Allocations: 33103)
Started GET "/site/basic-info.json" for 10.0.0.47 at 2022-08-10 11:55:47 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 80ms (Views: 0.8ms | ActiveRecord: 0.0ms | Allocations: 4260)

Do you know what I could do differently?

You can enter the running container and execute

message = TestMailer.send_test("test@gmail.com")
Email::Sender.new(message, :test_message).send

and inspect the exception that will be thrown for clues.

1 Like

This is what get from the first line

bash: syntax error near unexpected token `('

Oh, you need to drop into the rails console first. Go to the Discourse directory and enter rails c.

1 Like

This is what I get then

root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# rails c
bash: rails: command not found
root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# ls
Brewfile         Gemfile.lock  adminjs  config.ru                  docs                 lefthook.yml  package.json             plugins  test            yarn.lock
CONTRIBUTING.md  LICENSE.txt   app      d                          images               lib           passenger.3000.pid.lock  public   tmp
COPYRIGHT.md     README.md     bin      db                         install-imagemagick  licenses      passenger.8080.pid       script   translator.yml
Gemfile          Rakefile      config   discourse.sublime-project  jsapp                log           passenger.8080.pid.lock  spec     vendor

Okay, I was running now

RAILS_ENV=production bundle exec rails c

irb(main):002:0> message = TestMailer.send_test("test@gmail.com")
Traceback (most recent call last):
        2: from app/mailers/test_mailer.rb:7:in `send_test'
        1: from lib/email/build_email_helper.rb:8:in `build_email'
ArgumentError (:arguments expected to be an Array of individual string args)

Also, this here does not work:

root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# RAILS_ENV=production bundle exec rails c message = TestMailer.send_test("test@gmail.com")
bash: syntax error near unexpected token `('

Am I doing something wrong here?

Weird, this works just fine on my install:

[5] pry(main)> message = TestMailer.send_test("test@gmail.com")
  TranslationOverride Exists? (0.8ms)  SELECT 1 AS one FROM "translation_overrides" WHERE "translation_overrides"."locale" = 'en' AND "translation_overrides"."translation_key" = 'test_mailer.subject_template' LIMIT 1
   (0.2ms)  SELECT "translation_overrides"."translation_key", "translation_overrides"."value" FROM "translation_overrides" WHERE "translation_overrides"."locale" = 'en'
TestMailer#send_test: processed outbound mail in 259.9ms
=> #<Mail::Message:212740, Multipart: false, Headers: <From: "Discourse" <noreply@unconfigured.discourse.org>>, <Reply-To: "Discourse" <noreply@unconfigured.discourse.org>>, <To: test@gmail.com>, <Subject: [Discourse] Email Deliverability Test>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <X-Auto-Response-Suppress: All>, <Auto-Submitted: auto-generated>>

Since you are using an #unsupported-install packaged by Bitnami, it’s expected for it to be broken on subtle ways. We do not support such installs here, so you will want to reach out to their own support channel at Issues · bitnami/charts · GitHub.

1 Like

Hi @Falco many thanks for betting back to me.

What do you mean by unsupported installs? I am happy to go with more supported installs. :slight_smile:

Can I still get everything done with a helm chart then?

You cannot. Only the official install is supported. See Can Discourse ship frequent Docker images that do not need to be bootstrapped?.

I helped someone with a K8s install last week. It took me and a couple of talented engineers over 6 hours (but it might have been 10,not counting the time they spent without me) to get it going using their tooling.

I’ve considered creating images that should be launched from a helm chart, but haven’t don’t it yet. If you have a budget, please contact me via pm or email and I might be able to help.

2 Likes