A platform for community discussion. Free, open, simple.
FIX: disable smtp_should_reject code
Michael Brown06b34d5d817c
diff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rbindex a6250c4a16e..59d95aa1863 100644--- a/app/controllers/admin/email_controller.rb+++ b/app/controllers/admin/email_controller.rb@@ -66,23 +66,7 @@ class Admin::EmailController < Admin::AdminController# and was used only in the public mail-receiver's fast rejection code,# which is removed in https://github.com/discourse/mail-receiver/pull/33def smtp_should_reject- params.require(:from)- params.require(:to)- # These strings aren't localized; they are sent to an anonymous SMTP user.- if !User.with_email(Email.downcase(params[:from])).exists? && !SiteSetting.enable_staged_users- render json: {- reject: true,- reason: "Mail from your address is not accepted. Do you have an account here?",- }- elsif Email::Receiver.check_address(Email.downcase(params[:to])).nil?- render json: {- reject: true,- reason:- "Mail to this address is not accepted. Check the address and try to send again?",- }- else- render json: { reject: false }- end+ render json: { reject: false }enddef handle_maildiff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rbindex 6f9841d4616..8baec4f7073 100644--- a/spec/requests/admin/email_controller_spec.rb+++ b/spec/requests/admin/email_controller_spec.rb@@ -46,6 +46,54 @@ RSpec.describe Admin::EmailController doendend+ describe "#smtp_should_reject" do+ before { sign_in(admin) }++ it "does not reject with no params" do+ get "/admin/email/smtp_should_reject.json"+ expect(response.status).to eq(200)+ result = response.parsed_body++ expect(result["reject"]).to be false+ end++ it "does not reject with blank to/from" do+ get "/admin/email/smtp_should_reject.json", params: { from: "", to: "" }+ expect(response.status).to eq(200)+ result = response.parsed_body++ expect(result["reject"]).to be false+ end++ it "does not reject with blank to" do+ get "/admin/email/smtp_should_reject.json", params: { from: "[email protected]", to: "" }+ expect(response.status).to eq(200)+ result = response.parsed_body++ expect(result["reject"]).to be false+ end++ it "does not reject with blank from" do+ get "/admin/email/smtp_should_reject.json", params: { from: "", to: "[email protected]" }+ expect(response.status).to eq(200)+ result = response.parsed_body++ expect(result["reject"]).to be false+ end++ it "does not reject with to/from specified" do+ get "/admin/email/smtp_should_reject.json",+ params: {+ from: "[email protected]",+ to: "[email protected]",+ }+ expect(response.status).to eq(200)+ result = response.parsed_body++ expect(result["reject"]).to be false+ end+ end+describe "#test" docontext "when logged in as an admin" dobefore { sign_in(admin) }