Mailers - wordjelly/Auth GitHub Wiki
premailer-rails is added as a gem into the daughter app. It does not seem to work if added as a gem into the engine itself. No additional configuration is needed other than adding the gem to the Gemfile. With pre-mailer , as long as you add the following into your layout:
<html>
<head>
<%= stylesheet_link_tag "auth/application", media: "all" %>
<%= stylesheet_link_tag "https://fonts.googleapis.com/icon?family=Material+Icons", media: "all" %>
</head>
<body>
<%= yield %>
</body>
</html>
So premailer-rails will now pick up whatever stylesheet was mentioned, here and use it. So you can style your templates as if they are normal html.erb views, using all the css classes like usual.
MailGun is just an adapter for action_mailer. It's configuration is specified in the development.rb file of the daughter app. It is not specific to the engine. The gem is also included in the daughter app's gems. Basically mailgun is totally decoupled from the engine. Its API key, and domain name are not added to the preinitializer, but directly used in the development.rb file, because , the Auth.configuration is nil if referenced in the development.rb or any environment files.
This is the default mailer used by the engine, for notifications. It inherits from ::ApplicationMailer, i.e from the base mailer of the daughter app , and NOT from the engines base mailer. It will thus use the layout specified in the daughter app.(mailer.html.erb) It has only one method:
def notification(resource,notification)
@resource = resource
@notification = notification
mail to: @resource.email, subject: @notification.email_subject
end
It will look for a view , named notification.html.erb. To use this mailer, create a mailer in the daughter app using
rails g mailer MyMailer
After that edit it so that it subclasses from Auth::Notifier. Then edit the mailer.html.erb layout as your app needs. Then create a view called notification.html.erb in your views/my_mailer/ directory.
Suppose you don't provide this view, the delivery will fail, saying missing template. There is currently no way to reference the template in the engine, and so for the moment you need to provide your own template.
If deliver_later is called, it defaults to using the 'inline' adapter. This adapter is the default active job adapter, and since action_mailer implements active_job by default, inline is the method used. In order to use sidekiq as the backend, it has to be added at the level of application.rb. Refer to the following link: sidekiq-action-mailer