Derive smtp_from_address from BASE_URL when no SMTP_FROM_ADDRESS set

install-doc
Marcin Kulik 7 years ago
parent 1ce5c6cbde
commit c9d334bd00

@ -1,8 +1,6 @@
## Base URL of your asciinema web app instance
BASE_URL=http://localhost:3000
MAILNAME=localhost
## Run `docker-compose run --rm web bundle exec rake secret`
## and copy generated secret here
SECRET_KEY_BASE=
@ -10,6 +8,15 @@ SECRET_KEY_BASE=
DATABASE_URL=postgresql://postgres@postgres/postgres
REDIS_URL=redis://redis:6379
### E-mail delivery
## Outgoing mail hostname, used by namshi/smtp container.
MAILNAME=localhost
## "From" field for all emails sent by this instance.
## Default: asciinema <hello@hostname-from-base-url>
# SMTP_FROM_ADDRESS=admin@example.com
### File store
## By default we use local filesystem dir ("uploads" in app root dir).

@ -1,5 +1,5 @@
class Notifications < ActionMailer::Base
default from: CFG.from_email
default from: CFG.smtp_from_address
def self.delay_login_request(user_id, token)
delay.login_request(user_id, token)

@ -16,7 +16,7 @@ module Asciinema
attribute :secret_key_base, String
attribute :admin_ids, Array[Integer]
attribute :smtp_settings, Hash
attribute :from_email, String, default: "asciinema <hello@asciinema.org>"
attribute :smtp_from_address, String
def home_asciicast
if home_asciicast_id
@ -30,6 +30,10 @@ module Asciinema
URI.parse(base_url).scheme
end
def hostname
URI.parse(base_url).hostname
end
def hostname_with_port
uri = URI.parse(base_url)
hwp = uri.hostname
@ -45,6 +49,9 @@ module Asciinema
scheme == 'https'
end
def smtp_from_address
super || "asciinema <hello@#{hostname}>"
end
end
end

Loading…
Cancel
Save