From c51af1333806b9d7e2de165b00b0dca5d8cd5dce Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 5 Apr 2017 12:46:56 -0400 Subject: [PATCH] smtp_should_reject API: use better approach to find user email. --- app/controllers/admin/email_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rb index 0d9d0aca269..f77c64d7784 100644 --- a/app/controllers/admin/email_controller.rb +++ b/app/controllers/admin/email_controller.rb @@ -73,7 +73,7 @@ class Admin::EmailController < Admin::AdminController params.require(:from) params.require(:to) # These strings aren't localized; they are sent to an anonymous SMTP user. - if User.find_by_email(params[:from]).nil? && !SiteSetting.enable_staged_users + if !User.exists?(email: Email.downcase(params[:from])) && !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?" }