-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I have a case where I'm setting up users in a staging environment. I still want to be able to send email because I need to test on staging that emails are getting sent and that they look correct. However, the "fake" users I setup will have bad emails. This causes my bounce rates to skyrocket. For now, I can do some additional checks and avoid sending if their email matches something..
What would be cool is if we had a way to quick short-circuit the sending so it temporarily flips over to DevStrategy, or maybe just logs the email like it was sending, but doesn't actually send...
# sends real email
WelcomeUser.new(user_one).deliver_later
Cabron.temp_config(disable_sending: true) do
# doesn't actually send
WelcomeUser.new(user_two).deliver_later
end
# sends again
WelcomeUser.new(user_three).deliver_laterThis interface might be ok, but the issue here is that there could be email sending all over the place in your app. Maybe there could be a method on your emailable object that handles it?
class User < BaseModel
def emailable : Carbon::Address
if email_is_phony?
Carob::PhonyAddress.new(email)
else
Carbon::Address.new(email)
end
end
endThen internally if it sees you have a PhonyAddress it doesn't actually send..