mailer: send account emails as "asxp.io admin"
Invite and reset mails reused MAIL_FROM, whose display name is still "IE Sergei Poljanski Contact Form" from the removed contact form. Keep its verified address but use "asxp.io admin" as the name (overridable with ADMIN_MAIL_NAME). Assisted-by: Claude:opus-5
This commit is contained in:
parent
bf4f270fb4
commit
12d29dec0c
2 changed files with 11 additions and 1 deletions
|
|
@ -71,8 +71,16 @@ module Mailer
|
|||
end
|
||||
|
||||
# Invite / password-reset email with a one-time link.
|
||||
# Account mail keeps MAIL_FROM's verified address but not its display name
|
||||
# ("… Contact Form"); ADMIN_MAIL_NAME overrides the default.
|
||||
def admin_from
|
||||
addr = Mail::Address.new(ENV.fetch('MAIL_FROM'))
|
||||
addr.display_name = ENV.fetch('ADMIN_MAIL_NAME', 'asxp.io admin')
|
||||
addr.format
|
||||
end
|
||||
|
||||
def account_link(to:, username:, url:, kind:)
|
||||
from = ENV.fetch('MAIL_FROM')
|
||||
from = admin_from
|
||||
subj, intro, ttl =
|
||||
if kind == 'invite'
|
||||
['Your asxp.io admin account', "An account \"#{username}\" was created for you on the asxp.io admin.\nSet your password here:", '48 hours']
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ class UsersAdminTest < Minitest::Test
|
|||
refute carol.can?('bingo', 'write')
|
||||
assert_nil carol.password_digest
|
||||
assert_equal ['carol@example.com'], Mail::TestMailer.deliveries.last.to
|
||||
assert_equal 'asxp.io admin', Mail::TestMailer.deliveries.last[:from].display_names.first
|
||||
assert_equal ['test@example.com'], Mail::TestMailer.deliveries.last.from
|
||||
get '/admin/users'
|
||||
assert_includes last_response.body, 'emailed to carol@example.com'
|
||||
assert_includes last_response.body, '/admin/invite/'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue