Skip to content

Short circuit email sending #61

@jwoertink

Description

@jwoertink

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_later

This 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
end

Then internally if it sees you have a PhonyAddress it doesn't actually send..

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA new requested feature / option

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions