Skip to main content
Version: 0.3

Create emailing backends

Marten lets you easily create custom emailing backends that you can then use as part of your application when it comes to sending emails.

Basic backend definition

Defining an emailing backend is as simple as creating a class that inherits from the Marten::Emailing::Backend::Base abstract class and that implements a unique #deliver method. This method takes a single email argument (instance of Marten::Emailing::Email), corresponding to the email to deliver.

For example:

class CustomEmailingBackend < Marten::Emailing::Backend::Base
def deliver(email : Email)
# Deliver the email!
end
end

Enabling the use of custom emailing backends

Custom emailing backends can be used by assigning an instance of the corresponding class to the emailing.backend setting.

For example:

config.emailing.backend = CustomEmailingBackend.new