FEATURE: new 'auto_generated_whitelist' site setting

This commit is contained in:
Régis Hanol 2016-04-11 22:47:34 +02:00
parent a299231f9a
commit 56089c4856
5 changed files with 21 additions and 0 deletions

View File

@ -1169,6 +1169,7 @@ en:
delete_email_logs_after_days: "Delete email logs after (N) days. 0 to keep indefinitely"
max_emails_per_day_per_user: "Maximum number of emails to send users per day. 0 to disable the limit"
enable_staged_users: "Automatically create staged users when processing incoming emails."
auto_generated_whitelist: "List of email addresses that won't be checked for auto-generated content."
manual_polling_enabled: "Push emails using the API for email replies."
pop3_polling_enabled: "Poll via POP3 for email replies."

View File

@ -565,6 +565,9 @@ email:
min: 0
max_emails_per_day_per_user: 100
enable_staged_users: true
auto_generated_whitelist:
default: ''
type: list
files:
max_image_size_kb:

View File

@ -118,6 +118,7 @@ module Email
end
def is_auto_generated?
return false if SiteSetting.auto_generated_whitelist.split('|').include?(@from_email)
@mail[:precedence].to_s[/list|junk|bulk|auto_reply/i] ||
@mail[:from].to_s[/(mailer-?daemon|postmaster|noreply)@/i] ||
@mail.header.to_s[/auto[\-_]?(response|submitted|replied|reply|generated|respond)|holidayreply|machinegenerated/i]

View File

@ -142,6 +142,11 @@ describe Email::Receiver do
expect(topic.posts.last.raw).to eq("This email was sent with an invalid from header field.")
end
it "doesn't raise an AutoGeneratedEmailError when the mail is auto generated but is whitelisted" do
SiteSetting.auto_generated_whitelist = "foo@bar.com|discourse@bar.com"
expect { process(:auto_generated_whitelisted) }.not_to raise_error
end
describe 'Unsubscribing via email' do
let(:last_email) { ActionMailer::Base.deliveries.last }

View File

@ -0,0 +1,11 @@
Return-Path: <discourse@bar.com>
From: White List Ed <discourse@bar.com>
To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
Date: Fri, 15 Jan 2016 00:12:43 +0100
Message-ID: <1@foo.bar.mail>
Auto-Submitted: auto-generated
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Lorem ipsum dolor sit amet, consectetur adipiscing elit.