-
-
Save Fivell/7570698 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Base class | |
class DynamicHostMailer < ActionMailer::Base | |
def initialize method_name=nil, host, *args | |
@host = host | |
super method_name, *args | |
end | |
def url_options | |
# Host should be checked against a relevant whitelist, this is only an example | |
{ host: @host } | |
end | |
end | |
# Mailer | |
class SomeMailer < DynamicHostMailer | |
def my_mail user | |
mail to: user.email, from: "[email protected]", subject: "This is an email" | |
end | |
end | |
# Sending | |
SomeMailer.my_mail request.host_with_port, user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment