emails: fix sending emails to invalid addresses.
Fix mailers to not attempt deliveries to invalid or nonexistent email addresses. This usually happened when someone changed their email, and we tried to send a confirmation email to a nonexistent address.
This commit is contained in:
@@ -141,7 +141,7 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def send_email
|
||||
if is_recipient? && !is_deleted? && to.receive_email_notifications? && to.can_receive_email?
|
||||
if is_recipient? && !is_deleted? && to.receive_email_notifications?
|
||||
UserMailer.dmail_notice(self).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
@@ -361,11 +361,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
module EmailMethods
|
||||
def email_with_name
|
||||
"#{name} <#{email_address.address}>"
|
||||
end
|
||||
|
||||
def can_receive_email?(require_verification: true)
|
||||
def can_receive_email?(require_verified_email: true)
|
||||
email_address.present? && email_address.is_deliverable? && (email_address.is_verified? || !require_verification)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user