Discourse Sending Double E-mail

Hello, I am using self-hosted Discourse on my server. I am on the latest dev build as of now: Commits · discourse/discourse · GitHub

I am noticing Discourse sends email 2 times when a user signs up or gets a private message etc.

I can recreate this when I sign up a new user. I don’t know how can I troubleshoot this or what’s the exact problem or if this could be a problem of my e-mail server… I found some similar topics but they are couple of years old so I wanted to open a new topic.

Thank your for the help!

Do you see any information in your site’s Sent Emails logs related to these emails? Note that you can use the inputs at the top of that page to filter emails by User, To Address, or Email Type:

If this is a bug, it would be good to know exactly what the duplicate emails are being sent for.

What type of email are you getting when a user signs up? Is it telling you that there are users who require approval?

For the emails related to private messages, are these for messages that users have sent to you?

2 Likes

Hello,

In that page even when it’s sending double it only shows as one.

Though one strange thing happened. With the protonmail.com domain it didn’t send a double but with anonaddy.com there is a double e-mail. This makes me think maybe this issue is tied back to the mail server not Discourse.

Although I get double emails from my own domain/mail server as well. Can we trust that the email is not shown in the sent page then it’s %100 Discourse is not sending double e-mail?

Thank you.

If you look at the headers of the double emails you should be able to tell where the problem occurred.

Check the received-by headers specifically.

2 Likes

Okay it looks like both are coming from Discourse then if I got it right:

First mail:

Return-Path: <SRS0=ll8P=FH=anonaddy.com=b_na4w2nlvmv3gizdenmya_gq4wmodfhfrwm@Mail Server>
Delivered-To: Email Address
Received: from mail2.anonaddy.me (mail2.anonaddy.me [***.***.***.***])
	by Mail Server (Postfix) with ESMTPS id A9132370DA
	for Email Address; Sat, 23 Sep 2023 11:06:42 +0300 (+03)
Received: from mail2.anonaddy.me (mail2.anonaddy.me [127.0.0.1])
	by mail2.anonaddy.me (Postfix) with ESMTPS id 64958FA584
	for Email Address; Sat, 23 Sep 2023 09:06:41 +0100 (BST)
DKIM-Signature: [Truncated]
From: [Sender]
To: Email Address
Subject: =?utf-8?Q?=5BBilin=C3=A7li?= Teknoloji
 =?utf-8?Q?T=C3=BCketicileri=5D_Hesab=C4=B1n=C4=B1z=C4=B1_ona?=
 =?utf-8?Q?ylaman=C4=B1z_i=C3=A7in_an=C4=B1msat=C4=B1c=C4=B1?=
Feedback-ID: F:28f5e9fd-7ba5-4466-8b17-b52f087bd332:anonaddy
Message-ID: [Message ID]
Received: from Mail Server ([***.***.***.***]) by
 mail2.anonaddy.me (Postfix) with ESMTPS id 70F86100233 for
 Email Address; Sat, 23 Sep 2023 09:06:37 +0100 (BST)

Second Mail (same, double, you can see they are apart by seconds):

Return-Path: <SRS0=mdkr=FH=anonaddy.com=b_payts6dtgn5dkodznftq_my3tgntdgvqwk@Mail Server>
Delivered-To: Email Address
Received: from mail2.anonaddy.me (mail2.anonaddy.me [***.***.***.***])
	by Mail Server (Postfix) with ESMTPS id D2066370DA
	for Email Address; Sat, 23 Sep 2023 11:06:54 +0300 (+03)
Received: from mail2.anonaddy.me (mail2.anonaddy.me [127.0.0.1])
	by mail2.anonaddy.me (Postfix) with ESMTPS id 68CBC107D41
	for Email Address; Sat, 23 Sep 2023 09:06:54 +0100 (BST)
DKIM-Signature: [Truncated]
From: [Sender]
To: Email Address
Subject: =?utf-8?Q?=5BBilin=C3=A7li?= Teknoloji
 =?utf-8?Q?T=C3=BCketicileri=5D_Hesab=C4=B1n=C4=B1z=C4=B1_ona?=
 =?utf-8?Q?ylaman=C4=B1z_i=C3=A7in_an=C4=B1msat=C4=B1c=C4=B1?=
Feedback-ID: F:28f5e9fd-7ba5-4466-8b17-b52f087bd332:anonaddy
Message-ID: [Message ID]
Received: from Mail Server ([***.***.***.***]) by
 mail2.anonaddy.me (Postfix) with ESMTPS id E34B6100233 for
 Email Address; Sat, 23 Sep 2023 09:06:51 +0100 (BST)
1 Like

these are the interesting bits.

Is the message-ID the same?

Next check Mail Server’s logs to find out if Discourse sent one message vs. two and what’s the history for the email that hit anonaddy’s mail servers as 70F86100233 and E34B6100233.

4 Likes

Message ID’s are different.

First one is: Message-ID: <6172c966-5777-44c2-988f-6acdd7ff33ff@btt.community>
Second one is: Message-ID: <70297dae-5cb7-467b-980d-ef6dcfeea220@btt.community>

I checked out my mail server logs like this: cat mail.log | grep 70297dae

Output:

Sep 30 13:20:18 yuno postfix/cleanup[1559656]: 7C0F03D047: message-id=<70297dae-5cb7-467b-980d-ef6dcfeea220@btt.community>
Sep 30 13:20:38 yuno postfix/cleanup[1559656]: 88FE33D027: message-id=<70297dae-5cb7-467b-980d-ef6dcfeea220@btt.community>
Sep 30 13:20:44 yuno dovecot: lda(nonrelated@x.x.me)<1559829><m0KuF3z2F2UVzRcAMzq6nQ>: sieve: msgid=<70297dae-5cb7-467b-980d-ef6dcfeea220@btt.community>: stored mail into mailbox 'INBOX'

Same with other messag id: cat mail.log | grep 6172c966

Output:

Sep 30 13:20:43 yuno postfix/cleanup[1559799]: D3D4A3D059: message-id=<6172c966-5777-44c2-988f-6acdd7ff33ff@btt.community>
Sep 30 13:20:49 yuno postfix/cleanup[1559656]: EFEBC3D027: message-id=<6172c966-5777-44c2-988f-6acdd7ff33ff@btt.community>
Sep 30 13:20:49 yuno dovecot: lda(nonrelated@x.x.me)<1559834><Z0kBEIH2F2UazRcAMzq6nQ>: sieve: msgid=<6172c966-5777-44c2-988f-6acdd7ff33ff@btt.community>: stored mail into mailbox 'INBOX'

But in my admin panel it still looks like it sent only one:

I’ve seen an issue similar to this before with a server running dovecot. There was an issue with the dovecot side that was causing the redelivery.

Let me see if I can find the info.

Edit: still trying to find the info. I forgot how much data I would be searching through. :slight_smile:

4 Likes

I guess Claudia can’t find that information. Any other suggestions on how can we pinpoint and fix the issue would be appreciated because I am clueless. Thank you. :slight_smile:

Did you find a solution?

I once was struggling with a similar behavior. Users got hammered with emails, which the mail server sent but in discourse’s view were not sent.

My hypothesis was that it is possible that discourse gives a job to the mail server and there is a timeout during the process, which causes this to look like a fail to discourse even though the mail was sent. The failed job is then repeated and results in a new mail.

I was happy to resolve this by killing jobs in sidekiq, restarting the mail server and tinkering with fail2ban rules.