How to get Discourse to work with Postfix

I've tried everything, the firewall rules, app.yml settings, postfix main.cf settings...Even took into account the container IP address. I am at a loss, please do not recommend me an email service either as I have external email sources which discourse also failed to connect too. Basically I'm trying to get discourse to send ONE SINGLE EMAIL through postfix on port 25 (ISP isn't blocking, nor my firewalls), I've tried for 3 weeks now and I'm tired of this, I really don't want to drop this as it's a very good forum but it's making it very hard to even initially setup.

All I'm asking is a "how-to" get discourse to speak to postfix, googlefu had failed me in this task and I have nowhere else to go.

Right now I have an active admin account by manually enabling it cause, you guessed it, I didn't get the verification email. I'll provide any files such as settings and logs upon request.

Can you send mail with postfix normally? Do you see anything in /var/log/mail.log (on the postfix server) when trying to send mail from discourse?

I use iRedMail as my mail server, it works flawlessly. Plus it doesn't report anything in /var/log/mail.log since Discourse is in a container, you can only rely on the Discourse front-end UI when you sign into admin and the production.log when you /.launcher enter app (basically logging into another instance/vm).

If it weren't for this container setup, I guarantee that there would have been no issue on my part. Would you like my mail and production logs?

I don't really have any experience with containers. If you're not seeing any activity in your mail log (on the mail server) when trying to send mail from discourse then it's likely a problem with discourse (or the container ) not being able to communicate with the mail server.

If you do see activity then it might give you an idea of what the problem is.

yeah bro lets see em.

Ok, after some experimentation, I now get discourse to speak to postfix, however it now refused to AUTH discourse and has a STARTTLS error, I've tried many combinations but this part looks promising. Here's a slice of the mail.log:

Apr 16 15:01:16 fmisgaming postfix/master[5702]: daemon started -- version 2.11.3, configuration /etc/postfix
Apr 16 15:06:16 fmisgaming postfix/qmgr[5704]: 8B36AADD: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 15:06:17 fmisgaming postfix/local[7499]: 8B36AADD: to=[email protected], relay=local, delay=366, delays=366/0.06/0/0.1, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log file $
Apr 16 15:16:16 fmisgaming postfix/qmgr[5704]: 8B36AADD: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 15:16:16 fmisgaming postfix/local[9485]: 8B36AADD: to=[email protected], relay=local, delay=966, delays=966/0.04/0/0.07, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log file$
Apr 16 15:21:16 fmisgaming postfix/qmgr[5704]: 463795D3: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 15:21:16 fmisgaming postfix/qmgr[5704]: 9F6922C51: from=[email protected], size=36197, nrcpt=1 (queue active)
Apr 16 15:21:16 fmisgaming postfix/local[11441]: 9F6922C51: to=[email protected], relay=local, delay=66059, delays=66059/0.02/0/0.07, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 15:21:16 fmisgaming postfix/local[11440]: 463795D3: to=[email protected], relay=local, delay=152462, delays=152462/0.05/0/0.1, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 15:35:01 fmisgaming postfix/postscreen[14116]: CONNECT from [172.17.0.2]:54532 to [192.168.2.250]:25
Apr 16 15:35:01 fmisgaming postfix/postscreen[14116]: PASS OLD [172.17.0.2]:54532
Apr 16 15:35:01 fmisgaming postfix/smtpd[14119]: connect from unknown[172.17.0.2]
Apr 16 15:35:01 fmisgaming postfix/smtpd[14119]: lost connection after AUTH from unknown[172.17.0.2]
Apr 16 15:35:01 fmisgaming postfix/smtpd[14119]: disconnect from unknown[172.17.0.2]
Apr 16 15:36:16 fmisgaming postfix/qmgr[5704]: 5C02A42F0: from=[email protected], size=36197, nrcpt=1 (queue active)
Apr 16 15:36:16 fmisgaming postfix/qmgr[5704]: 8B36AADD: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 15:36:16 fmisgaming postfix/local[14209]: 5C02A42F0: to=[email protected], relay=local, delay=12966, delays=12966/0.04/0/0.09, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 15:36:16 fmisgaming postfix/local[14210]: 8B36AADD: to=[email protected], relay=local, delay=2166, delays=2166/0.02/0/0.1, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log fi$
Apr 16 15:38:21 fmisgaming postfix/anvil[14122]: statistics: max connection rate 1/60s for (smtpd:172.17.0.2) at Apr 16 15:35:01
Apr 16 15:38:21 fmisgaming postfix/anvil[14122]: statistics: max connection count 1 for (smtpd:172.17.0.2) at Apr 16 15:35:01
Apr 16 15:38:21 fmisgaming postfix/anvil[14122]: statistics: max cache size 1 at Apr 16 15:35:01
Apr 16 15:53:07 fmisgaming postfix/postscreen[15476]: CONNECT from [172.17.0.2]:54604 to [192.168.2.250]:25
Apr 16 15:53:07 fmisgaming postfix/postscreen[15476]: PASS OLD [172.17.0.2]:54604
Apr 16 15:53:07 fmisgaming postfix/smtpd[15477]: connect from unknown[172.17.0.2]
Apr 16 15:53:07 fmisgaming postfix/smtpd[15477]: lost connection after AUTH from unknown[172.17.0.2]
Apr 16 15:53:07 fmisgaming postfix/smtpd[15477]: disconnect from unknown[172.17.0.2]
Apr 16 15:54:43 fmisgaming postfix/master[5702]: terminating on signal 15
Apr 16 15:54:44 fmisgaming postfix/master[15726]: daemon started -- version 2.11.3, configuration /etc/postfix
Apr 16 16:14:44 fmisgaming postfix/qmgr[15728]: 8B36AADD: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 16:14:44 fmisgaming postfix/local[19848]: 8B36AADD: to=[email protected], relay=local, delay=4474, delays=4474/0.05/0/0.07, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log f$
Apr 16 16:15:05 fmisgaming postfix/postscreen[19939]: CONNECT from [172.17.0.2]:54825 to [192.168.2.250]:25
Apr 16 16:15:05 fmisgaming postfix/postscreen[19939]: PASS OLD [172.17.0.2]:54825
Apr 16 16:15:05 fmisgaming postfix/smtpd[19940]: connect from unknown[172.17.0.2]
Apr 16 16:15:05 fmisgaming postfix/smtpd[19940]: lost connection after STARTTLS from unknown[172.17.0.2]
Apr 16 16:15:05 fmisgaming postfix/smtpd[19940]: disconnect from unknown[172.17.0.2]
Apr 16 16:18:25 fmisgaming postfix/anvil[19942]: statistics: max connection rate 1/60s for (smtpd:172.17.0.2) at Apr 16 16:15:05
Apr 16 16:18:25 fmisgaming postfix/anvil[19942]: statistics: max connection count 1 for (smtpd:172.17.0.2) at Apr 16 16:15:05
Apr 16 16:18:25 fmisgaming postfix/anvil[19942]: statistics: max cache size 1 at Apr 16 16:15:05
Apr 16 16:29:44 fmisgaming postfix/qmgr[15728]: 463795D3: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 16:29:44 fmisgaming postfix/qmgr[15728]: 9F6922C51: from=[email protected], size=36197, nrcpt=1 (queue active)
Apr 16 16:29:44 fmisgaming postfix/local[22608]: 463795D3: to=[email protected], relay=local, delay=156570, delays=156570/0.05/0/0.1, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 16:29:44 fmisgaming postfix/local[22609]: 9F6922C51: to=[email protected], relay=local, delay=70167, delays=70166/0.03/0/0.11, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 16:44:44 fmisgaming postfix/qmgr[15728]: 5C02A42F0: from=[email protected], size=36197, nrcpt=1 (queue active)
Apr 16 16:44:44 fmisgaming postfix/local[26389]: 5C02A42F0: to=[email protected], relay=local, delay=17074, delays=17074/0.04/0/0.09, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 17:24:44 fmisgaming postfix/qmgr[15728]: 8B36AADD: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 17:24:44 fmisgaming postfix/local[3168]: 8B36AADD: to=[email protected], relay=local, delay=8674, delays=8674/0.06/0/0.09, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log fi$
Apr 16 17:39:44 fmisgaming postfix/qmgr[15728]: 463795D3: from=[email protected], size=36194, nrcpt=1 (queue active)
Apr 16 17:39:44 fmisgaming postfix/qmgr[15728]: 9F6922C51: from=[email protected], size=36197, nrcpt=1 (queue active)
Apr 16 17:39:44 fmisgaming postfix/local[5430]: 463795D3: to=[email protected], relay=local, delay=160770, delays=160770/0.04/0/0.08, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open lo$
Apr 16 17:39:44 fmisgaming postfix/local[5431]: 9F6922C51: to=[email protected], relay=local, delay=74367, delays=74367/0.02/0/0.1, dsn=4.3.0, status=deferred (temporary failure. Command output: Can't open log $
Apr 17 11:42:26 fmisgaming postfix/master[1533]: daemon started -- version 2.11.3, configuration /etc/postfix

It seems it cleans out the production.log whenever I kill the server...

Is the username actually [email protected] and not [email protected]?

No, I've replace the real username with 'user', the domain name is sv01.fmisgaming.com but when you use an email it will be only [email protected].

What I mean is if the username is [email protected] but you're seeing [email protected] in the logs then that is probably why you're getting an authentication error, as the username is incorrect.

You could also try disabling authentication for the discourse server, so it can send e-mail without needing credentials. To do that edit your /etc/postfix/main.cf file (on the mail server) and make sure the line smtpd_relay_restrictions = contains permit_mynetworks then add your server's IP address (looks like 172.17.0.2) to the mynetworks = line.

Wow, I didn't think that would matter, so discourse is pulling the hostname instead of making the app.yml setting email the priority...I think we found a flaw in discourse here boys.

I've already made an exception in main.cf of those settings (and permit_mynetworks):

mynetworks 127.0.0.0/8 172.17.0.0/16 192.168.2.0/24

I'll see if I can resolve the username@address problem.

1 Like

...it works...I feel so stupid when I looked at my logs again...

Sorry for wasting your time.

All good, glad you got it working

@shu_kaze

I have the same problem.
How did you solved it ? lost connection after AUTH

I am using a username and pw
if I telnet from discourse to postfix I can send email without authenticating myself
but I can’t dind how to config discourse to not authenticate

I authorized DIscourse IP to relay on the POstfix server

JF

I recommend signing up and using Mailgun. They give you 10k free emails per month.

https://www.mailgun.com/

@Dexter_Kane @shu_kaze

Hello.
It’s a similar problem. The log files display the sending of a test message, but there is no mention of sending invitations. I do not know where to go next to solve the problem.

Necros twice, somehow went under our nose the first time.