rails/actionmailer/CHANGELOG.md
Alex Ghiculescu 9a2cf33f21
Introduce ActionMailer::FormBuilder
Fixes https://github.com/rails/rails/issues/48477

Using forms inside emails is not common, but it's possible, and it's also possible to share views between controllers and mailers. Currently if a controller sets a `default_form_builder` that's different from the global config, mailers that use the same views will not default to the same `FormBuilder`. To fix this, this PR adds a `default_form_builder` method for mailers that does the same thing as its controller sibling.
2023-09-25 20:33:22 +00:00

3.5 KiB

  • Introduce ActionMailer::FormBuilder

    Use the default_form_builder method in mailers to set the default form builder for templates rendered by that mailer. Matches the behaviour in Action Controller.

    Alex Ghiculescu

Rails 7.1.0.beta1 (September 13, 2023)

  • Mailers are listed in alphabetical order on the mailer preview page now.

    Martin Spickermann

  • Deprecate passing params to assert_enqueued_email_with via the :args kwarg. assert_enqueued_email_with now supports a :params kwarg, so use that to pass params:

    # BEFORE
    assert_enqueued_email_with MyMailer, :my_method, args: { my_param: "value" }
    
    # AFTER
    assert_enqueued_email_with MyMailer, :my_method, params: { my_param: "value" }
    

    To specify named mailer args as a Hash, wrap the Hash in an array:

    assert_enqueued_email_with MyMailer, :my_method, args: [{ my_arg: "value" }]
    # OR
    assert_enqueued_email_with MyMailer, :my_method, args: [my_arg: "value"]
    

    Jonathan Hefner

  • Accept procs for args and params in assert_enqueued_email_with

    assert_enqueued_email_with DeliveryJob, params: -> p { p[:token] =~ /\w+/ } do
      UserMailer.with(token: user.generate_token).email_verification.deliver_later
    end
    

    Max Chernyak

  • Added *_deliver callbacks to ActionMailer::Base that wrap mail message delivery.

    Example:

    class EventsMailer < ApplicationMailer
      after_deliver do
        User.find_by(email: message.to.first).update(email_provider_id: message.message_id, emailed_at: Time.current)
      end
    end
    

    Ben Sheldon

  • Added deliver_enqueued_emails to ActionMailer::TestHelper. This method delivers all enqueued email jobs.

    Example:

    def test_deliver_enqueued_emails
      deliver_enqueued_emails do
        ContactMailer.welcome.deliver_later
      end
      assert_emails 1
    end
    

    Andrew Novoselac

  • The deliver_later_queue_name used by the default mailer job can now be configured on a per-mailer basis. Previously this was only configurable for all mailers via ActionMailer::Base.

    Example:

    class EventsMailer < ApplicationMailer
      self.deliver_later_queue_name = :throttled_mailer
    end
    

    Jeffrey Hardy

  • Email previews now include an expandable section to show all headers.

    Headers like Message-ID for threading or email service provider specific features like analytics tags or account metadata can now be viewed directly in the mailer preview.

    Matt Swanson

  • Default ActionMailer::Parameterized#params to an empty Hash

    Sean Doyle

  • Introduce the capture_emails test helper.

    Returns all emails that are sent in a block.

    def test_emails
      emails = capture_emails do
        ContactMailer.welcome.deliver_now
        ContactMailer.welcome.deliver_later
      end
      assert_email "Hi there", emails.first.subject
    end
    

    Alex Ghiculescu

  • Added ability to download .eml file for the email preview.

    Igor Kasyanchuk

  • Support multiple preview paths for mailers.

    Option config.action_mailer.preview_path is deprecated in favor of config.action_mailer.preview_paths. Appending paths to this configuration option will cause those paths to be used in the search for mailer previews.

    fatkodima

Please check 7-0-stable for previous changes.