Email reply system issue sent a million unwanted mails

(Rahul Bansal) #1

There are more than a million emails sent similar to below one in a month from SMTP (configured via Amazon SES):

I am not sure what is going wrong. It seems self-emails are sent in loop. Almost 30k emails daily.

Gmail “Show original” mail copy is here - discourse-reply-email-issue · GitHub

Thought SMTP, notification and all other types of emails are working fine. We are using Amazon SES and suddenly cost of SES is jumped close to $100. We started to debug and found something wrong on our discourse setup.

Admin email looks like below:

I disabled “email reply” temporarily and this email flooding is stopped.

I am wondering if this a bug because this started around a month back and only thing we did with discourse in last month is “update”. No settings has been changed.

Below are relevant settings which I think has something to do with this. “reply by email enabled” was enabled when we experience huge surge in mail volume.

Is this something to do with “reply by email address”. I didn’t add {reply_key} in that address. I did not think it was necessary and can create an issue like this. If it’s necessary then IMHO, it would have been better to have validation or mention of such requirement in description.

I really wish to enable “reply by email” so any help to correct our config will be really useful.


(Jeff Atwood) #2

@neil can we add regex validation here in site settings to ensure the mail field has the key present within the curly braces in the email address there.

(Rahul Bansal) #3

@codinghorror So it looks like my mistake was not adding {reply_key} in email address field.

On sidenote, I also feel there should be some extra code to avoid “infinite loop”. What happened in our case seems like infinite loop.

I couldn’t find how it started but basically when discourse detected first fault email, it replied with “Email Issue” email.

As this “new” email went to mailbox used for “reply parsing”, reply parser logic picked this “new” email again. It triggered another email and the chain continued for a month.

This might have gone unnoticed for long, hasn’t we saw huge charges in Amazon bill for SES.

I really think when first time reply by email did not work, I should have digged deeper into it. But as nobody complained, I ignored the error.

Should I add {reply_key} in email address and proceed do I need to look into anything else?

Thanks for looking into this.

Discourse sending huuuuge number of emails
(Jeff Atwood) #4

I added a regex check here

  default: ''
  regex: "%{reply_key}"

So the %{reply_key} must exist in the string for it to be accepted as a valid site setting. Hopefully that will prevent this problem in the future. Sorry about that.

(Rahul Bansal) #5

Great. :smile:

I added {reply_key} on my end and things seems to be working fine.

I also needed to delete the mailbox itself which is dedicated for replies. Gmail was crashing when I was trying to delete/archive/mark-as-read all unwanted emails. And even though I asked Gmail to enable POP for future emails, somehow POP logic was fetching unwanted emails present in Gmail account and going into infinite loop.

I must have read settings description seriously and I should not have ignored previous Amazon billing alerts! :wink:

This is solved on my end.

(Jeff Atwood) #7

I hope you added %{reply_key} and not {reply_key}

(Rahul Bansal) #8

Yep. Thanks for reminder. :smile: