Local host as domain server?

(Arthur Geron) #1

I’m testing a local instance of Discourse Docker, I don’t quite understand what the ‘hostname’ should be or how I would set it up, although I’ve managed to set a smtp server (with DKIM and SPF) and successfully test it otherwise the e-mails aren’t being delivered…
I’ve set the hostname server as localhost but it is no working, all the the SMTP settings are correct so what am I doing wrong?

EDIT(Info for anyone going through the same trouble as me):

Apparently, hostname is what your discourse will use to find your DNS to validate your settings and get some info, one of which seems to be MX which will refer to your e-mail adress hostname.


I’m using discourse.focusefield.com.br as my subdomain for my discourse app, (I’m running it on DigitalOcean), and MailJet for my e-mails, so my DNS configs on focusefield.com.br configs are now as you can check bellow:
MX: in-v3.mailjet.com
NS: ns1.digitalocean.com, ns2.digitalocean.com and ns3.digitalocean.com
A: discourse.focusefield.com.br value: myDigitalOceansDiscourseAppIP (hiding it for safety reasons)
And the SPF and DKIM configs on TXT settings (not placing here for safety reasons as well).
Now finally I can set the Discourse’s hostname to be discourse.focusefield.com.br !
This seems to be the correct setup, I only wish there was an easy way to setup the hostname without having to go trough all this.

(Eli the Bearded) #2

Inside the container, the “localhost” will be the container. You need to use the FQDN of your host machine as the name of the mail server.

This also means you can’t limit SMTP connections to just, and have to be much more careful in your mail server config.

FYI, for my dev usage I use MailCatcher instead of a real MTA. It’s a simple daemon that accepts email and presents all of it in an HTML page. I find it simpler for test work. Mail never goes out, and MailCatcher doesn’t keep email between restarts, so that may be a non-starter for your dev work.

(Arthur Geron) #3

Thank you for shedding a light on this for me. I used localhost -f to see the FQDN of the docker and set it up as a hostname, but it didn’t work. Btw I think I wasn’t clear on the SMTP part, I have a valid SMTP configuration as you can see bellow:

DISCOURSE_DEVELOPER_EMAILS: ‘noreply@focusefield.com.br’

DISCOURSE_SMTP_ADDRESS: in-v3.mailjet.com

I tried using the ‘docker FQDN’ as the hostname :
DISCOURSE_HOSTNAME: UK-OP-app I’ve also tried using DISCOURSE_HOSTNAME: in-v3.mailjet.com and DISCOURSE_HOSTNAME: localhost, but none of these configs worked.

Is there any tutorial on how to set the FQDN on a container after creating it? The tutorial I’ve found on Docker’s official documentation about FQDN seems to be something you set up before creating a container, but since the docker instance is created automatically using the builder script ( according to the tutorial ) that is not possible.

(Eli the Bearded) #4

You don’t need to give the container a name at all. Either the hostname you assign in app.yml (DISCOURSE_HOSTNAME:) or the email addresses you fill in the Admin Settings will be enough.

(Arthur Geron) #5

I see! Finally I got it, set the hostname to docker.focusefield.com.br (this seems to be the correct setting)… Thank you!!
I’m rebuilding it and I will see if it’s working now.

(Arthur Geron) #6

I’ve set a subdomain for discourse as : discourse.focusefield.com.br
set the hostname as : discourse.focusefield.com.br
SMTP same as before but with the new domain, tried ports 465 and 587, also tried por 25 without tls, none of them worked, completely lost here.
I set up a discourse instance on DigitalOcean, follow the tutorial and set everything accordingly (including the hostname), I’m waiting for the NS to load up my new changes on the DNS server and will come back with the results shortly.

(Arthur Geron) #7

I’ve set it up with DigitalOcean and MailJet, everything SHOULD be working, but in docker logs I ge t the error ( Job Execution Expired), when checking deeper into the logs it says the following:

/usr/local/lib/ruby/2.4.0/net/smtp.rb:539:in initialize' /usr/local/lib/ruby/2.4.0/net/smtp.rb:539:inopen’
/usr/local/lib/ruby/2.4.0/net/smtp.rb:539:in tcp_socket' /usr/local/lib/ruby/2.4.0/net/smtp.rb:549:inblock in do_start’
/usr/local/lib/ruby/2.4.0/timeout.rb:103:in timeout' /usr/local/lib/ruby/2.4.0/net/smtp.rb:548:indo_start’
/usr/local/lib/ruby/2.4.0/net/smtp.rb:518:in start' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/mail-2.6.6/lib/mail/network/delivery_methods/smtp.rb:111:indeliver!’
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/mail-2.6.6/lib/mail/message.rb:2149:in do_delivery' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/mail-2.6.6/lib/mail/message.rb:237:inblock in deliver’
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer/base.rb:543:in block in deliver_mail' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:inblock in instrument’
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in instrument' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:ininstrument’
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer/base.rb:541:in deliver_mail' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/mail-2.6.6/lib/mail/message.rb:237:indeliver’
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer/message_delivery.rb:85:in deliver_now' /var/www/discourse/lib/email/sender.rb:184:insend’
/var/www/discourse/app/jobs/regular/user_email.rb:41:in execute' /var/www/discourse/app/jobs/regular/critical_user_email.rb:10:inexecute’
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform’

(Eli the Bearded) #8

From your edited first post:

That’s about what you need to do. Your reference to “local host” in the topic title and original question sounded like a quite different problem.

FYI: your information isn’t “hidden for safety”. DNS records are easy to look-up. That’s what DNS does: publish data in an easy to look-up way. All this stuff that seems so complicated becomes routine after a while.

(Arthur Geron) #9

hahah true you are right, I wish they’d explain it what the hostname is for and how to set one up more in depth! Anyway it’s still not working, I’ve posted the logs for reference :confused:

(Eli the Bearded) #10

Have you used the email troubleshooting guide?

It goes through all the testing steps.

(Arthur Geron) #11

Yes, several times actually, that is how I was able to open the logs.
Mailjet DKIM and SPF settings are working, I’ve managed to successfully send e-mails using Telnet and online SMTP testing tools using mailjet domain, but doesn’t work on discourse for some reason.

(Eli the Bearded) #12

To be sure, you tried the telnet method from your droplet? The logs you posted look clipped, but I see references to a timeout which makes me wonder if your instance is not connecting to your mail server.

(Arthur Geron) #13

Turns out I can connect to the mailserver from my local computer, but not from my droplet! Why ??

(Eli the Bearded) #14

Ask Digital Ocean. We can’t help with that.

(Arthur Geron) #15

They automatically block SMTP protocol until you agree to an ‘no-spamming’ US agreement, everything is working now, thanks a lot.