Help needed, I'm blocked in debugging email config (Infomaniak/Brevo)

Hello !

I’m installing discourse for our little non-profit association. I have chosen to get an ubuntu 22.04 cloud instance in a Public Cloud from Infomaniak and to have our transactional emails in Brevo because they have 300 mails/month in their free plan.

I went through several problems, one by one, to setup the server, and the documentation and the posts here helped me a lot…

BUT
Now I’ve reached a point where I don’t know how to advance.

  1. My instance is accessible on our forum.aether-labs.fr sub-domain

  2. My account at Brevo is working correctly, as I succeed in sending emails from noreply@forum.aether-labs.fr from thunderbird

  3. But I don’t receive my first admin email to validate the account.

So I read in details the post Troubleshoot email on a new Discourse install (no link because new user rule) and tried stuff.

  1. The app container (seems to ?) succeed in reaching brevo smtp server port
root@server-1:/var/discourse# 
root@server-1:/var/discourse# ./launcher enter app
x86_64 arch detected.
root@server-1-app:/var/www/discourse# 
root@server-1-app:/var/www/discourse# openssl s_client -connect smtp-relay.sendinblue.com:587 -starttls smtp
CONNECTED(00000003)
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
---
Certificate chain
 0 s:CN = *.sendinblue.com
   i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
 1 s:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
   i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
 2 s:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
   i:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGODCCBSCgAwIBAgIQf3BN6DJXk+R4MhMClPwXSzANBgkqhkiG9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issuer=C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA

---
No client certificate CA names sent
Peer signing digest: SHA512
Peer signature type: RSA
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 5482 bytes and written 476 bytes
Verification: OK
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: FF96A2562FFDC00C5948FE7E6123CE9CD4CFB4939A4546728F60584ED2EC12EB
    Session-ID-ctx: 
    Master-Key: 287A2ECAB44E3F1EB919B4AD0EF98981A05F866381485781BB46AFEA2F361E987C31E57DA1098B01F69B75679E07E430
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 6d 30 ab bf 0a 44 79 06-0a 1a 67 1a 25 b5 f8 05   m0...Dy...g.%...
    0010 - 8e 33 6c 9a db 35 cd 9e-64 d6 a3 44 59 36 d4 e1   .3l..5..d..DY6..
    0020 - 69 b2 46 6a d5 7a 22 25-c2 36 bd bc ef ca d8 bf   i.Fj.z"%.6......
    0030 - 1c e2 b5 31 4e ab 43 cf-ea a0 1a b8 39 69 cd 5c   ...1N.C.....9i.\
    0040 - 15 b5 94 17 9c 70 d0 9d-ff 7c 7f e9 3f c8 87 a2   .....p...|..?...
    0050 - d0 12 5d a2 2b 6c e3 54-aa 33 10 fa b5 08 57 9f   ..].+l.T.3....W.
    0060 - 64 ce cc 08 53 24 f1 5c-4f 6b 4c 19 f1 f8 83 be   d...S$.\OkL.....
    0070 - 97 11 17 3f 83 5f 9f 9c-16 73 86 98 c8 d6 72 a8   ...?._...s....r.
    0080 - 44 7a bd 43 e3 40 44 a5-f4 6d 7f 36 19 e4 f3 84   Dz.C.@D..m.6....
    0090 - ec 3f 0b 65 0c 53 ef 73-ef 43 19 8c 34 27 87 40   .?.e.S.s.C..4'.@
    00a0 - 7e 52 5f 6f 7a 2d e6 08-a6 fc 6f 77 a9 47 f3 fa   ~R_oz-....ow.G..
    00b0 - eb 56 ac 1d f0 42 de 45-37 22 ec 5e 13 48 09 41   .V...B.E7".^.H.A

    Start Time: 1700936536
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
---
250 STARTTLS
^C
root@server-1-app:/var/www/discourse# 
root@server-1-app:/var/www/discourse# 

The last log is 250 STARTTLS instead of the 250 DSN specified in the former post and it seems ok for the non-expert in me.

  1. But the discourse-doctor can’t send email and tells the port is closed (i’ve tried with 587, 2525 and 465 without starttls)
==================== 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) [contact@aether-labs.fr]: test-f2ps9wb2f@srv1.mail-tester.com
Sending mail to test-f2ps9wb2f@srv1.mail-tester.com. . . 
Testing sending to test-f2ps9wb2f@srv1.mail-tester.com using smtp-relay.sendinblue.com:587, username:forum@aether-labs.fr with plain auth.
======================================== ERROR ========================================
Connection to port 587 failed.
====================================== SOLUTION =======================================
The most likely problem is that your server has outgoing SMTP traffic blocked.
If you are using a service like Mailgun or Sendgrid, try using port 2525.
=======================================================================================

So as from (4) it seems that the outgoing SMTP traffic is not blocked, I don’t know how to continue and what configuration to change to have a correct config of the transactional emails.

You might check with the provider of your vm to see if your outgoing ports are blocked.

Thanks @pfaffman !
I just sent them an email.

But the fact that

openssl s_client -connect smtp-relay.sendinblue.com:587 -starttls smtp

works is strange, if I put smtp-relay.sendinblue.com:586 I don’t have the results, so I would guess the traffic is not blocked, isn’t it ? I mean, the packets do reach smtp-relay.sendinblue.com:587 if there are responses…

So the support told me everything was ok with the conf and that outgoings ports where not blocked.

So I tried to go to the send email through openssl completely, and yes, I succeed to send me an email from inside the docker container.

root@server-1-app:/var/www/discourse#  openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587

EHLO jai
AUTH PLAIN
AGZvcnVtQGFldGhlci1sYWJ... # cut for security
mail from: noreply@forum.aether-labs.fr
rcpt to: test-j0erqjxm2@srv1.mail-tester.com
data
subject: test smtp from inside


ok
.

… but the discourse-doctor command still tells me the connection to smtp-relay.sendinblue.com:587 failed.

So I read the script discourse-doctor, and I saw that the test is linked to a rake job called emails:test, that I found in lib/tasks/emails.rake and saw that this message happen when the “execution expired”.

Is there an option to change the timeout value before considering the execution expired ?

Edit: ok, so if I edit app/services/email_settings_validator.rb and put manually the timeout to 30, the connection is ok, but the send mail still fails (linked to TestMailer, I guess I may not increase that one…)

root@server-1-app:/var/www/discourse# rake emails:test[test-j0erqjxm2@srv1.mail-tester.com]
Testing sending to test-j0erqjxm2@srv1.mail-tester.com using smtp-relay.sendinblue.com:587, username:forum@aether-labs.fr with plain auth.
SMTP server connection successful.
Sending to test-j0erqjxm2@srv1.mail-tester.com. . . 
Sending mail failed.
execution expired

Since I’m really at the minimum requirements from discourse in this instance (1 VCPU + 2GB RAM), I may also try to upgrade to something better (like 2 VCPU + 4GB RAM).

Do you have in the env:

DISCOURSE_SMTP_ENABLE_START_TLS: true

It’s the default, so you shouldn’t need it, but maybe you turned it off?

It is set to true, yes !
(I’ve edited my previous message with my experiment with timeouts…)

How long does the openssl command take to connect and negotiate TLS?

almost 10 sec

real	0m9.798s
user	0m0.007s
sys	0m0.010s

Wow, that is an absurdly long time.

Does it take the same amount of time from the host system?

I just made the test
~10 sec from docker
<1 sec from the host (certainly the time for me to press ctrl+D to stop, it is really almost instant)

This is reasonable.

It seems you have something fundamentally broken with container networking… these two commands should take the same amount of time:

(from host):point_down:t3:

○ → time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.277s
user	0m0.007s
sys	0m0.011s

(via docker):point_down:t3:

○ → docker run --rm discourse/base:2.0.20231023-1945 bash -c 'time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null' > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.239s
user	0m0.006s
sys	0m0.000s
1 Like

it is not :sob:

root@server-1:/var/discourse# time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.126s
user	0m0.003s
sys	0m0.007s
root@server-1:/var/discourse# docker run --rm discourse/base:2.0.20231023-1945 bash -c 'time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null' > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m8.125s
user	0m0.007s
sys	0m0.000s

… should I uninstall / reinstall docker ?
I only did some apt commands and let it by default from docker-ce, so I don’t know what can be wrong…

the only mod I did was to add the dns as suggested in another post because I first had “unknown host” errors

root@server-1:/var/discourse# cat /etc/docker/daemon.json
{
  "dns": ["83.166.143.51", "83.166.143.52", "8.8.8.8"]
}

OK it works !

I changed my /etc/docker/daemon.json so google (8.8.8.8) is first and not last, and I got a decent response time for STARTTLS… and discourse-doctor successfully send emails :slight_smile:

Thanks a lot for your time @supermathie and @pfaffman

I will add a note on the other post to tells google should be the first in the list !

Not all suggestions are applicable to all cases. That’s also kind of the danger of adopting someone else’s advice just because it worked for them.

In your case, it seems that the google nameservers are more reliable than the ones provided by your ISP, so you should use those.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.