FEATURE: new 'auto_generated_whitelist' site setting
This commit is contained in:
parent
a299231f9a
commit
56089c4856
|
@ -1169,6 +1169,7 @@ en:
|
||||||
delete_email_logs_after_days: "Delete email logs after (N) days. 0 to keep indefinitely"
|
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"
|
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."
|
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."
|
manual_polling_enabled: "Push emails using the API for email replies."
|
||||||
pop3_polling_enabled: "Poll via POP3 for email replies."
|
pop3_polling_enabled: "Poll via POP3 for email replies."
|
||||||
|
|
|
@ -565,6 +565,9 @@ email:
|
||||||
min: 0
|
min: 0
|
||||||
max_emails_per_day_per_user: 100
|
max_emails_per_day_per_user: 100
|
||||||
enable_staged_users: true
|
enable_staged_users: true
|
||||||
|
auto_generated_whitelist:
|
||||||
|
default: ''
|
||||||
|
type: list
|
||||||
|
|
||||||
files:
|
files:
|
||||||
max_image_size_kb:
|
max_image_size_kb:
|
||||||
|
|
|
@ -118,6 +118,7 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_auto_generated?
|
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[:precedence].to_s[/list|junk|bulk|auto_reply/i] ||
|
||||||
@mail[:from].to_s[/(mailer-?daemon|postmaster|noreply)@/i] ||
|
@mail[:from].to_s[/(mailer-?daemon|postmaster|noreply)@/i] ||
|
||||||
@mail.header.to_s[/auto[\-_]?(response|submitted|replied|reply|generated|respond)|holidayreply|machinegenerated/i]
|
@mail.header.to_s[/auto[\-_]?(response|submitted|replied|reply|generated|respond)|holidayreply|machinegenerated/i]
|
||||||
|
|
|
@ -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.")
|
expect(topic.posts.last.raw).to eq("This email was sent with an invalid from header field.")
|
||||||
end
|
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
|
describe 'Unsubscribing via email' do
|
||||||
let(:last_email) { ActionMailer::Base.deliveries.last }
|
let(:last_email) { ActionMailer::Base.deliveries.last }
|
||||||
|
|
||||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue