# How to get Discourse to work with Postfix

**URL:** https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602
**Category:** Self-hosting
**Created:** [August 12, 2020, 9:13am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602 "2020-08-12T09:13:38Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 9:13am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/1 "2020-08-12T09:13:38Z")

</div>

Hello. I have a discourse without a docker on my local server. Also installed iRedMail. First I tried to use an smtp-server from [mail.ru](http://mail.ru). Test messages were sent, as well as invitations. But no email notifications came in, and the password was reset. I decided that I should install my local mail server and see the logs there why messages do not leave. I did. Local messages come between mailboxes. That’s what you need for testing. Thought it would be enough for local discourse and mail. Set your local smtp server. Sent a test email… and it got there! Winner(no). Looked at /var/log/mail.log of the mail server.

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/a/5a12464364950cafea895ada87a14d4ac062660e.png)  
Okay. Now I’m sending an invitation to the same box… Looking at the mail server logs… …and nothing. It’s empty. I don’t know what the problem is.

All I’m asking is a “how-to” get discourse to speak to postfix.

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.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 12, 2020, 9:25am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/2 "2020-08-12T09:25:22Z")

</div>

Dear @Anv

Welcome to Discourse Meta.

Normally when we have these kind of problem we run something like:

```plaintext
sendmail -vvv A_VALID_EMAIL_ADDRESS < email.txt

```

and this will give you a very verbose output of the handshake between you and the SMTP server; and normally that verbose logging will provide you the clues to solve your issue.

Hope this helps.

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 9:31am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/3 "2020-08-12T09:31:28Z")

</div>

Hi! I don’t have much experience. Installed dicsourse and a mail server for the first time. Could you elaborate on what exactly I need to do? Thank you.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 12, 2020, 9:33am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/4 "2020-08-12T09:33:18Z")

</div>

> [@Anv](#):
>
> Could you elaborate on what exactly I need to do?

Hey @Anv

First, you need to temporarily “forget” about Discourse, and focus on getting your SMTP mail relay up and running, tested and to make sure it can relay mail.

Have you done that part already?

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 11:12am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/5 "2020-08-12T11:12:13Z")

</div>

> [@neounix](#):
>
> Have you done that part already?

I installed iRedMail using this link.

> **[How to Easily Set Up a Full-Featured Mail Server on Ubuntu 22.04 with iRedMail](https://www.linuxbabe.com/mail-server/ubuntu-22-04-iredmail-email-server)**
>
> This tutorial will be showing you how to use iRedMail to quickly set up a full-featured mail server on Ubuntu 22.04, saving you lots of time and headaches.

Without a step 5 and 9.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 12, 2020, 11:17am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/6 "2020-08-12T11:17:33Z")

</div>

Hey @Anv

That’s an advanced install for sure.

Did you test it without discourse and insure it is working?

Something like:

```plaintext
sendmail -vvv A_VALID_EMAIL_ADDRESS < email.txt

```

?

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 1:11pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/7 "2020-08-12T13:11:07Z")

</div>

I made 2 mailboxes in my local domain “@ugda.space”. And the messages are coming to each other. To gmail/mail/yandex boxes, the messages don’t reach each other. I didn’t set it up, because I thought I could have enough intra-local communication for the tests.

---

<div class="post-metadata">

### Author: ![Mevo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mevo/32/187732_2.png) [@Mevo](https://meta.discourse.org/u/Mevo)
#### Post date: [August 12, 2020, 1:44pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/8 "2020-08-12T13:44:18Z")

</div>

@Anv Let me be blunt: A good unwritten rule should be something like “don’t ask people to talk to you if you’re not willing to put the effort to listen to them”. By “listening”, I mean considering what they’re telling you. Participating to a forum counts as “asking people to talk to you”, I guess. Especially if you’re asking for help.

Keeping on repeating the same thing, and forcing your interlocutor to also repeat himself doesn’t lead anywhere. For anyone.

Now, why have you not run this command line already ?

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 1:52pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/9 "2020-08-12T13:52:47Z")

</div>

> [@Mevo](#):
>
> Now, why have you not run this command line already ?

I’m sorry. But I guess I didn’t fully understand what was required of me. I did everything right?

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/4/b42541b7cf4de42f98052f84093c431cce5f003f.png)

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 12, 2020, 2:46pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/10 "2020-08-12T14:46:26Z")

</div>

Hey @Anv

I understand your frustration; and I’m sorry I don’t have more free time to debug all your SMTP relay problem every time you reply.

It seems like your SMTP mail host is receiving mail; but that does not necessarily mean it will work as an SMTP relay.

I recall, off the top of my head, there is a flag to use sendmail and other mail clients to check if the SMTP host is working properly as a relay. You might do some research on the `sendmail -G` option (or look for another way to test). Basically, you need to send the mail to a test email address different than the host you are working on, using your newly minted SMTP host as a relay.

> Some History

In the old days, most SMTP hosts would relay mail out-of-the-box; but then all the SMTP hosts on the net became big SPAM boxes because spammers would just exploit the relay functionality (unknown to the owner of the box) and spam the world.

The bottom line is that you need to check to see if your newly minted SMTP host can relay the mail for you.

Did you look closely at your configuration tutorial and see if it mentioned setting up the SMTP host as a relay?

I’m just thinking out loud and hope this helps you in some small way get to the next step in your SMTP host project.

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 12, 2020, 2:50pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/11 "2020-08-12T14:50:31Z")

</div>

Okay, I think I hear you. I’m gonna see if I can find out any information on this.

---

<div class="post-metadata">

### Author: ![Mevo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mevo/32/187732_2.png) [@Mevo](https://meta.discourse.org/u/Mevo)
#### Post date: [August 12, 2020, 3:52pm UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/12 "2020-08-12T15:52:12Z")

</div>

You mentioned you have Discourse installed without Docker. Would it possible for you to do a fresh new install the “classic” way (with docker) by entering the email you created during this new install ? Or you can’t run docker on the machine you’re using ?

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 13, 2020, 1:02am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/13 "2020-08-13T01:02:13Z")

</div>

> [@Mevo](#):
>
> “classic” way (with docker)

I tried with the docker, but there was no mail at all. I couldn’t even create an administrator account. I decided to expel the docker because I was inexperienced.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 13, 2020, 1:29am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/14 "2020-08-13T01:29:43Z")

</div>

> [@Anv](#):
>
> I tried with the docker, but there was no mail at all. I couldn’t even create an administrator account. I decided to expel the docker because I was inexperienced.

Hi @Mevo and @Anv

Good morning.

I’m sure it is not helpful, but as “just another datapoint”, I have never had any problem setting up SMTP mail on Discourse in either a Docker-based production install or a desktop macOS “no Docker” dev setup; but I have always used a third-party SMTP service.

You guys are getting my attention; and so now I am very interested in this little puzzle and will try to find time in the next few weeks to set up an SMTP relay on a VPS Ubuntu Linux slice and see if I can get Discourse to play ball with an “old fashioned” SMTP relay versus depending on “third party solutions”.

My apology in advance if it takes me a few weeks to build this configuration. I am falling behind on a bunch of boring government paper work because I have been having too much fun with learning Discourse plugin dev and how Rails works with all the moving parts.

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 13, 2020, 2:07am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/15 "2020-08-13T02:07:18Z")

</div>

Hi @neounix.

Anyway, thank you so much for helping me with this.

Perhaps my main problem is that I want to run this inside a LAN without access from an external network.

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 13, 2020, 3:21am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/16 "2020-08-13T03:21:20Z")

</div>

Discourse log during invitation sending

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/c/7c5b6416f8e90a6d3a0da3bfda9cf96de863461f.png)

---

<div class="post-metadata">

### Author: ![Anv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anv/32/137587_2.png) [@Anv](https://meta.discourse.org/u/Anv)
#### Post date: [August 13, 2020, 9:55am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/17 "2020-08-13T09:55:47Z")

</div>

Log says there’s a letter with an ID.  
Tried to find a mention of this ID  
1 ID - test message.  
2 ID - invitation

![image](https://global.discourse-cdn.com/meta/original/3X/0/7/079d9e7646027797b11428ab96b1270341b353e3.png)

---

<div class="post-metadata">

### Author: ![sonmicrosystems](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@sonmicrosystems](https://meta.discourse.org/u/sonmicrosystems)
#### Post date: [November 4, 2021, 10:08am UTC](https://meta.discourse.org/t/how-to-get-discourse-to-work-with-postfix/160602/18 "2021-11-04T10:08:49Z")

</div>

After some trials and errors, I’ve been able to make Discourse work with Postfix. Here are steps that I’ve used, hope they can be helpful:

1. Set a A record to point to your new server, says `forum.domain.com`

2. install postfix, set `forum.domain.com` as `myhostname` and add `172.17.0.0/16` to `mynetworks` so Discourse container can talk with Postfix without authentication. `172.17.0.0/16` is the default network used by Docker containers.

3. Make sure postfix can sending out emails. I prefer using `swaks`

4. In `containers/app.yml`, make sure to comment out the 3 lines for `DISCOURSE_SMTP_USER_NAME`, `DISCOURSE_SMTP_PASSWORD` and `DISCOURSE_SMTP_ENABLE_START_TLS`

5. To test, you can connect to the Discourse container by `docker exec -it app bash` and run:

6. Restart discourse with `./launcher rebuild app`. You should now be able to create new account and receive verification email.
