Sha256: bbaa09f2926bd68ab56cbe8c8604b71a1131e51f294d142b14e3b319b2757b77

Contents?: true

Size: 868 Bytes

Versions: 13

Compression:

Stored size: 868 Bytes

Contents

= Mailers

The mailer class, is not that different than what default Rails has to offer.

Mail classes are located in the `app/mailers/decidim/<my_module>` directory, and named: `<my_custom>_mailer.rb`.

```ruby
# frozen_string_literal: true

# app/mailers/decidim/my_module/my_custom_mailer.rb
module Decidim
  module MyModule
    class MyCustomMailer < Decidim::ApplicationMailer
      def greeting(user)
        with_user(user) do
          @user = user

          subject = I18n.t("greeting.subject", scope: "decidim.my_module.mailer.my_custom_mailer")
          mail(to: user.email, subject:)
        end
      end
    end
  end
end
```

Please notice the `with_user` method, that is being used to set the locale of the mailer to the user's locale.

== More information

- https://edgeguides.rubyonrails.org/action_mailer_basics.html[Action Mailer documentation]

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-0.29.1 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.4 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.29.0 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.3 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.29.0.rc4 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.29.0.rc3 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.29.0.rc2 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.29.0.rc1 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.2 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.1 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.0 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.0.rc5 docs/modules/develop/pages/classes/mailers.adoc
decidim-0.28.0.rc4 docs/modules/develop/pages/classes/mailers.adoc