How to configure Discourse to receive email from Mailgun?

I have a fully working Discourse installation (installed using the recommended approach) on a server (Linode) running Ubuntu. I can send email without issue and do new user sign-up.

We are using this feature Configuring incoming email to create new topics or group messages : Discourse needs to provide an incoming email address.

In mail gun I have created a Catch All route that forwards email to a webhook as described here: Discourse Mailgun Routes and I have installed the plugin.

However, looking at the Mailgun logs this fails. Any ideas how to do this?

{
	"timestamp": 1737657789.428326,
	"recipient-domain": "forum.domain.com",
	"envelope": {
		"transport": "http",
		"targets": "https://forum.domain.com/mailgun/routes/receive_mime",
		"sender": "me@myemail.com"
	},
	"primary-dkim": "",
	"delivery-status": {
		"code": 406,
		"session-seconds": 0.277,
		"message": "Not Acceptable",
		"attempt-no": 1,
		"description": ""
	},
	"event": "failed",
	"id": "4uIIPrRRTQOwluJaE-QpRA",
	"campaigns": null,
	"log-level": "error",
	"tags": [],
	"message": {
		"size": 4089,
		"headers": {
			"message-id": "CA+riLLnyMLCruT2DmhFjTuyvy7OtQ8NrT0X0m5PZXfK3uzwCEg@mail.gmail.com",
			"to": "domain+support-12@forum.domain.com",
			"subject": "Test",
			"from": "Me Me <me@myemail.com>"
		},
		"attachments": []
	},
	"recipient": "https://forum.domain.com/mailgun/routes/receive_mime",
	"user-variables": {},
	"flags": {
		"is-test-mode": false,
		"is-authenticated": false,
		"is-routed": false,
		"is-system-test": false
	},
	"storage": {
		"region": "us-east4",
		"env": "production",
		"key": "BAABAAAVXB5iOt41fPtDZaekVDDH1beaZA",
		"url": "https://storage-us-east4.api.mailgun.net/v3/domains/forum.domain.com/messages/BAABAAAVXB5iOt41fPtDZaekVDDH1beaZA"
	},
	"severity": "permanent"
}

The easiest and recommended way is to Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver

2 Likes

If you enable mailgun_log_rejections and send another email, there should be a rejection reason in your sidekiq logs (mailgun does not retain the response body so this is basically the only way) and that should tell you.

Otherwise you can use the mail-receiver setup if you would rather do that.

1 Like