Class: Hanami::Providers::Mailers Private
- Inherits:
-
Hanami::Provider::Source
- Object
- Dry::System::Provider::Source
- Hanami::Provider::Source
- Hanami::Providers::Mailers
- Defined in:
- lib/hanami/providers/mailers.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Registers the ‘“mailers.delivery_method”` component. This is an SMTP delivery method built from SMTP environment variables when present, otherwise the test delivery method.
SMTP env vars may take a per-slice prefix derived from the slice name (e.g. an “admin” slice reads ‘ADMIN__SMTP_ADDRESS`, falling back to `SMTP_ADDRESS`). Register your own `:mailers` provider if you need to use another delivery method or different setup logic.
In the test env, environment variables are ignored, and the test delivery method is always used, so the test suite can never send real email.
In the production env, warns noisily when there is no SMTP configuration, before falling back to the test delivery method. This ensures an app whose mail setup is a work in progress can still boot.
Constant Summary collapse
- SMTP_ENV_VARS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Maps SMTP environment variable names to their compatible delivery option keys.
Example values:
SMTP_ADDRESS=smtp.example.com SMTP_PORT=587 SMTP_USERNAME=postmaster@example.com SMTP_PASSWORD=s3cr3t SMTP_AUTHENTICATION=plain { "SMTP_ADDRESS" => :address, "SMTP_PORT" => :port, "SMTP_USERNAME" => :user_name, "SMTP_PASSWORD" => :password, "SMTP_AUTHENTICATION" => :authentication }.freeze
- SMTP_COERCIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Coercions applied to SMTP env var values, keyed by option. Options not listed here are passed through unchanged (as strings).
Hash.new(:itself.to_proc).update( port: ->(value) { Integer(value) }, authentication: ->(value) { value.to_sym } ).freeze
Instance Attribute Summary
Attributes inherited from Hanami::Provider::Source
Instance Method Summary collapse
- #start ⇒ Object private
Methods inherited from Hanami::Provider::Source
#initialize, #target_container
Constructor Details
This class inherits a constructor from Hanami::Provider::Source
Instance Method Details
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 |
# File 'lib/hanami/providers/mailers.rb', line 45 def start require "hanami/mailer" register "delivery_method", build_delivery_method end |